From 29030b54c98b0aee65fbc10ebf7ba36bed98c02c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 10 Aug 2013 18:02:44 +0200 Subject: util/Error: new error passing library Replaces GLib's GError. --- src/DatabaseGlue.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/DatabaseGlue.cxx') diff --git a/src/DatabaseGlue.cxx b/src/DatabaseGlue.cxx index 70b7acc9e..fb944dacc 100644 --- a/src/DatabaseGlue.cxx +++ b/src/DatabaseGlue.cxx @@ -24,6 +24,7 @@ #include "DatabaseSave.hxx" #include "DatabaseError.hxx" #include "Directory.hxx" +#include "util/Error.hxx" #include "conf.h" extern "C" { @@ -50,7 +51,7 @@ static bool db_is_open; static bool is_simple; bool -DatabaseGlobalInit(const config_param ¶m, GError **error_r) +DatabaseGlobalInit(const config_param ¶m, Error &error) { assert(db == NULL); assert(!db_is_open); @@ -61,12 +62,12 @@ DatabaseGlobalInit(const config_param ¶m, GError **error_r) const DatabasePlugin *plugin = GetDatabasePluginByName(plugin_name); if (plugin == NULL) { - g_set_error(error_r, db_quark(), 0, - "No such database plugin: %s", plugin_name); + error.Format(db_domain, + "No such database plugin: %s", plugin_name); return false; } - db = plugin->create(param, error_r); + db = plugin->create(param, error); return db != NULL; } @@ -89,13 +90,12 @@ GetDatabase() } const Database * -GetDatabase(GError **error_r) +GetDatabase(Error &error) { assert(db == nullptr || db_is_open); if (db == nullptr) - g_set_error_literal(error_r, db_quark(), DB_DISABLED, - "No database"); + error.Set(db_domain, DB_DISABLED, "No database"); return db; } @@ -131,17 +131,17 @@ db_get_directory(const char *name) } bool -db_save(GError **error_r) +db_save(Error &error) { assert(db != NULL); assert(db_is_open); assert(db_is_simple()); - return ((SimpleDatabase *)db)->Save(error_r); + return ((SimpleDatabase *)db)->Save(error); } bool -DatabaseGlobalOpen(GError **error) +DatabaseGlobalOpen(Error &error) { assert(db != NULL); assert(!db_is_open); -- cgit v1.2.3