diff options
Diffstat (limited to 'src/StickerDatabase.cxx')
-rw-r--r-- | src/StickerDatabase.cxx | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/StickerDatabase.cxx b/src/StickerDatabase.cxx index f153231de..8ed82c770 100644 --- a/src/StickerDatabase.cxx +++ b/src/StickerDatabase.cxx @@ -21,6 +21,8 @@ #include "StickerDatabase.hxx" #include "fs/Path.hxx" #include "Idle.hxx" +#include "util/Error.hxx" +#include "util/Domain.hxx" #include <string> #include <map> @@ -81,23 +83,19 @@ static const char sticker_sql_create[] = static sqlite3 *sticker_db; static sqlite3_stmt *sticker_stmt[G_N_ELEMENTS(sticker_sql)]; -static GQuark -sticker_quark(void) -{ - return g_quark_from_static_string("sticker"); -} +static constexpr Domain sticker_domain("sticker"); static sqlite3_stmt * -sticker_prepare(const char *sql, GError **error_r) +sticker_prepare(const char *sql, Error &error) { int ret; sqlite3_stmt *stmt; ret = sqlite3_prepare_v2(sticker_db, sql, -1, &stmt, NULL); if (ret != SQLITE_OK) { - g_set_error(error_r, sticker_quark(), ret, - "sqlite3_prepare_v2() failed: %s", - sqlite3_errmsg(sticker_db)); + error.Format(sticker_domain, ret, + "sqlite3_prepare_v2() failed: %s", + sqlite3_errmsg(sticker_db)); return NULL; } @@ -105,7 +103,7 @@ sticker_prepare(const char *sql, GError **error_r) } bool -sticker_global_init(Path &&path, GError **error_r) +sticker_global_init(Path &&path, Error &error) { int ret; @@ -118,7 +116,7 @@ sticker_global_init(Path &&path, GError **error_r) ret = sqlite3_open(path.c_str(), &sticker_db); if (ret != SQLITE_OK) { const std::string utf8 = path.ToUTF8(); - g_set_error(error_r, sticker_quark(), ret, + error.Format(sticker_domain, ret, "Failed to open sqlite database '%s': %s", utf8.c_str(), sqlite3_errmsg(sticker_db)); return false; @@ -128,9 +126,9 @@ sticker_global_init(Path &&path, GError **error_r) ret = sqlite3_exec(sticker_db, sticker_sql_create, NULL, NULL, NULL); if (ret != SQLITE_OK) { - g_set_error(error_r, sticker_quark(), ret, - "Failed to create sticker table: %s", - sqlite3_errmsg(sticker_db)); + error.Format(sticker_domain, ret, + "Failed to create sticker table: %s", + sqlite3_errmsg(sticker_db)); return false; } @@ -139,7 +137,7 @@ sticker_global_init(Path &&path, GError **error_r) for (unsigned i = 0; i < G_N_ELEMENTS(sticker_sql); ++i) { assert(sticker_sql[i] != NULL); - sticker_stmt[i] = sticker_prepare(sticker_sql[i], error_r); + sticker_stmt[i] = sticker_prepare(sticker_sql[i], error); if (sticker_stmt[i] == NULL) return false; } |