From ef97a7b517de1d2e7f4f6be4af89393603a6e281 Mon Sep 17 00:00:00 2001 From: ulrichbayer Date: Tue, 22 Nov 2016 23:07:05 +0100 Subject: [PATCH 1/2] Throw dedicated exceptions Use the already prepared exception classes no_rows and more_rows when there are no more rows or more rows than expected. --- hdr/sqlite_modern_cpp.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hdr/sqlite_modern_cpp.h b/hdr/sqlite_modern_cpp.h index 93bc94d8..3d09ca9b 100644 --- a/hdr/sqlite_modern_cpp.h +++ b/hdr/sqlite_modern_cpp.h @@ -174,11 +174,11 @@ namespace sqlite { if((hresult = sqlite3_step(_stmt.get())) == SQLITE_ROW) { call_back(); } else if(hresult == SQLITE_DONE) { - exceptions::throw_custom_error("no rows to extract: exactly 1 row expected"); + throw exceptions::no_rows("no rows to extract: exactly 1 row expected"); } if((hresult = sqlite3_step(_stmt.get())) == SQLITE_ROW) { - exceptions::throw_custom_error("not all rows extracted"); + throw exceptions::more_rows("not all rows extracted"); } if(hresult != SQLITE_DONE) { From 1a5b44315f32e5061b394486bef3683e5227c04f Mon Sep 17 00:00:00 2001 From: ulrichbayer Date: Wed, 23 Nov 2016 00:16:34 +0100 Subject: [PATCH 2/2] Remove unused function throw_custom_error --- hdr/sqlite_modern_cpp.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hdr/sqlite_modern_cpp.h b/hdr/sqlite_modern_cpp.h index 3d09ca9b..cbee439a 100644 --- a/hdr/sqlite_modern_cpp.h +++ b/hdr/sqlite_modern_cpp.h @@ -88,11 +88,6 @@ namespace sqlite { else if(error_code == SQLITE_NOTADB) throw exceptions::notadb(sqlite3_errstr(error_code)); else throw sqlite_exception(sqlite3_errstr(error_code)); } - - static void throw_custom_error(const char* str) { - throw std::runtime_error(str); - } - } class database;