[gom] gom: Use GomError rather than separate error domains
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gom] gom: Use GomError rather than separate error domains
- Date: Fri, 18 Apr 2014 17:46:56 +0000 (UTC)
commit 0a12f66ffa2a237db9734d1dd2cf06c88248a1d5
Author: Tristan Brindle <t c brindle gmail com>
Date: Sat Apr 19 00:59:13 2014 +0800
gom: Use GomError rather than separate error domains
Convert all functions to use the GomError domain for errors
https://bugzilla.gnome.org/show_bug.cgi?id=728491
gom/gom-adapter.c | 5 +++--
gom/gom-command.c | 11 ++++++-----
gom/gom-repository.c | 9 +++++----
gom/gom-resource.c | 5 +++--
4 files changed, 17 insertions(+), 13 deletions(-)
---
diff --git a/gom/gom-adapter.c b/gom/gom-adapter.c
index 9bc223c..ed64db7 100644
--- a/gom/gom-adapter.c
+++ b/gom/gom-adapter.c
@@ -21,6 +21,7 @@
#include "gom-adapter.h"
#include "gom-command.h"
+#include "gom-error.h"
G_DEFINE_TYPE(GomAdapter, gom_adapter, G_TYPE_OBJECT)
@@ -192,8 +193,8 @@ open_callback (GomAdapter *adapter,
flags = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE | SQLITE_OPEN_URI | SQLITE_OPEN_NOMUTEX;
ret = sqlite3_open_v2(uri, &adapter->priv->db, flags, NULL);
if (ret != SQLITE_OK) {
- g_simple_async_result_set_error(simple, GOM_ADAPTER_ERROR,
- GOM_ADAPTER_ERROR_OPEN,
+ g_simple_async_result_set_error(simple, GOM_ERROR,
+ GOM_ERROR_ADAPTER_OPEN,
_("Failed to open database at %s"), uri);
}
g_simple_async_result_set_op_res_gboolean(simple, ret == SQLITE_OK);
diff --git a/gom/gom-command.c b/gom/gom-command.c
index 645776f..88f4824 100644
--- a/gom/gom-command.c
+++ b/gom/gom-command.c
@@ -22,6 +22,7 @@
#include "gom-adapter.h"
#include "gom-command.h"
+#include "gom-error.h"
G_DEFINE_TYPE(GomCommand, gom_command, G_TYPE_OBJECT)
@@ -268,14 +269,14 @@ gom_command_prepare (GomCommand *command,
}
if (!priv->sql) {
- g_set_error(error, GOM_COMMAND_ERROR, GOM_COMMAND_ERROR_NO_SQL,
+ g_set_error(error, GOM_ERROR, GOM_ERROR_COMMAND_NO_SQL,
_("The command does not contain any SQL"));
return FALSE;
}
if (!(ret = (SQLITE_OK == sqlite3_prepare_v2(db, priv->sql, -1,
&priv->stmt, NULL)))) {
- g_set_error(error, GOM_COMMAND_ERROR, GOM_COMMAND_ERROR_SQLITE,
+ g_set_error(error, GOM_ERROR, GOM_ERROR_COMMAND_SQLITE,
_("sqlite3_prepare_v2 failed: %s: %s"),
sqlite3_errmsg(db), priv->sql);
}
@@ -302,7 +303,7 @@ gom_command_execute (GomCommand *command,
}
if (!priv->adapter || !(db = gom_adapter_get_handle(priv->adapter))) {
- g_set_error(error, GOM_COMMAND_ERROR, GOM_COMMAND_ERROR_SQLITE,
+ g_set_error(error, GOM_ERROR, GOM_ERROR_COMMAND_SQLITE,
_("Failed to access SQLite handle."));
return FALSE;
}
@@ -327,8 +328,8 @@ gom_command_execute (GomCommand *command,
*/
code = sqlite3_step(priv->stmt);
if (!(ret = (code == SQLITE_ROW || code == SQLITE_DONE))) {
- g_set_error(error, GOM_COMMAND_ERROR,
- GOM_COMMAND_ERROR_SQLITE,
+ g_set_error(error, GOM_ERROR,
+ GOM_ERROR_COMMAND_SQLITE,
"Failed to execute statement: %d", code);
}
return ret;
diff --git a/gom/gom-repository.c b/gom/gom-repository.c
index 13e7e86..25ececb 100644
--- a/gom/gom-repository.c
+++ b/gom/gom-repository.c
@@ -21,6 +21,7 @@
#include "gom-command.h"
#include "gom-command-builder.h"
#include "gom-cursor.h"
+#include "gom-error.h"
#include "gom-repository.h"
G_DEFINE_TYPE(GomRepository, gom_repository, G_TYPE_OBJECT)
@@ -680,8 +681,8 @@ gom_repository_find_one_cb (GObject *object,
}
if (!gom_resource_group_get_count(group)) {
- g_simple_async_result_set_error(simple, GOM_REPOSITORY_ERROR,
- GOM_REPOSITORY_ERROR_EMPTY_RESULT,
+ g_simple_async_result_set_error(simple, GOM_ERROR,
+ GOM_ERROR_REPOSITORY_EMPTY_RESULT,
_("No resources were found."));
g_simple_async_result_complete_in_idle(simple);
g_object_unref(simple);
@@ -726,8 +727,8 @@ gom_repository_find_one_sync (GomRepository *repository,
}
if (!gom_resource_group_get_count(group)) {
- g_set_error(error, GOM_REPOSITORY_ERROR,
- GOM_REPOSITORY_ERROR_EMPTY_RESULT,
+ g_set_error(error, GOM_ERROR,
+ GOM_ERROR_REPOSITORY_EMPTY_RESULT,
_("No resources were found."));
g_object_unref(group);
return NULL;
diff --git a/gom/gom-resource.c b/gom/gom-resource.c
index 9e62eb3..a4a969d 100644
--- a/gom/gom-resource.c
+++ b/gom/gom-resource.c
@@ -21,6 +21,7 @@
#include "gom-command.h"
#include "gom-command-builder.h"
+#include "gom-error.h"
#include "gom-filter.h"
#include "gom-repository.h"
#include "gom-resource.h"
@@ -675,8 +676,8 @@ gom_resource_fetch_m2m_cb (GomAdapter *adapter,
}
if (!gom_cursor_next(cursor)) {
- g_simple_async_result_set_error(simple, GOM_RESOURCE_ERROR,
- GOM_RESOURCE_ERROR_CURSOR,
+ g_simple_async_result_set_error(simple, GOM_ERROR,
+ GOM_ERROR_RESOURCE_CURSOR,
_("No result was returned from the cursor."));
goto out;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]