Skip to content

Commit 4c6d172

Browse files
committed
Extended error code and report error code when database opening fails
1 parent 2f33d3a commit 4c6d172

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/sqlite_db.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ SQLiteDB SQLiteDB::Open(const string &path, bool is_read_only, bool is_shared) {
3939
// FIXME: we should just make sure we are not re-using the same `sqlite3` object across threads
4040
flags |= SQLITE_OPEN_NOMUTEX;
4141
}
42-
SQLiteUtils::Check(sqlite3_open_v2(path.c_str(), &result.db, flags, nullptr), result.db);
42+
flags |= SQLITE_OPEN_EXRESCODE;
43+
auto rc = sqlite3_open_v2(path.c_str(), &result.db, flags, nullptr);
44+
if (rc != SQLITE_OK) {
45+
throw std::runtime_error("Unable to open database \"" + path + "\": " + string(sqlite3_errstr(rc)));
46+
}
4347
return result;
4448
}
4549

0 commit comments

Comments
 (0)