Skip to content

Throw dedicated exceptions #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions hdr/sqlite_modern_cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -174,11 +169,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) {
Expand Down