diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-01-21 14:32:02 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-06-13 17:29:48 +0100 |
commit | b0bf7561a6e85ea913d45cd732cf3e1f7abc3b43 (patch) | |
tree | 71d0a0c60caf2a062bcd1c3f2edbf9634e12d0b2 /p2pvr/daemon | |
parent | Add sandboxed database support to unit tests and lots of sample data (diff) | |
download | p2pvr-b0bf7561a6e85ea913d45cd732cf3e1f7abc3b43.tar.bz2 p2pvr-b0bf7561a6e85ea913d45cd732cf3e1f7abc3b43.tar.xz p2pvr-b0bf7561a6e85ea913d45cd732cf3e1f7abc3b43.zip |
Throw specific exception (NoRowsFound) when a row is required but none are returned
Diffstat (limited to 'p2pvr/daemon')
-rw-r--r-- | p2pvr/daemon/sqlSelectDeserializer.cpp | 6 | ||||
-rw-r--r-- | p2pvr/daemon/sqlSelectDeserializer.h | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/p2pvr/daemon/sqlSelectDeserializer.cpp b/p2pvr/daemon/sqlSelectDeserializer.cpp index 8217f1e..3f011a4 100644 --- a/p2pvr/daemon/sqlSelectDeserializer.cpp +++ b/p2pvr/daemon/sqlSelectDeserializer.cpp @@ -103,7 +103,7 @@ SqlSelectDeserializer::DeserializeSimple(Slicer::ModelPartPtr mp) { auto fmp = mp->GetAnonChild(); if (!cmd.fetch()) { - std::invalid_argument("No rows returned"); + throw NoRowsReturned(); } SqlSourcePtr h = new SqlSource(); const DB::Column & c = cmd[0]; @@ -114,7 +114,7 @@ SqlSelectDeserializer::DeserializeSimple(Slicer::ModelPartPtr mp) fmp->Complete(); } if (cmd.fetch()) { - std::invalid_argument("Too many rows returned"); + throw std::invalid_argument("Too many rows returned"); } } @@ -132,7 +132,7 @@ void SqlSelectDeserializer::DeserializeObject(Slicer::ModelPartPtr mp) { if (!cmd.fetch()) { - throw std::invalid_argument("No rows returned"); + throw NoRowsReturned(); } DeserializeRow(mp); if (cmd.fetch()) { diff --git a/p2pvr/daemon/sqlSelectDeserializer.h b/p2pvr/daemon/sqlSelectDeserializer.h index 008a87c..0c32811 100644 --- a/p2pvr/daemon/sqlSelectDeserializer.h +++ b/p2pvr/daemon/sqlSelectDeserializer.h @@ -4,6 +4,8 @@ #include <slicer/serializer.h> #include <selectcommand.h> +class NoRowsReturned : public std::exception { }; + class SqlSelectDeserializer : public Slicer::Deserializer { public: SqlSelectDeserializer(DB::SelectCommand &, IceUtil::Optional<std::string> typeIdCol = IceUtil::Optional<std::string>()); |