2
* Copyright (C) 1999, 2000 Red Hat Inc.
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Library General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Library General Public License for more details.
14
* You should have received a copy of the GNU Library General Public
15
* License along with this library; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
20
#include "gconf-error.h"
21
#include "gconf-internals.h"
24
static const gchar* err_msgs[] = {
27
N_("Configuration server couldn't be contacted"),
28
N_("Permission denied"),
29
N_("Couldn't resolve address for configuration source"),
30
N_("Bad key or directory name"),
32
N_("Corrupt data in configuration source database"),
34
N_("Key operation on directory"),
35
N_("Directory operation on key"),
36
N_("Can't overwrite existing read-only value"),
37
N_("Object Activation Framework error"),
38
N_("Operation not allowed without configuration server"),
39
N_("Failed to get a lock"),
40
N_("No database available to save your configuration")
43
static const int n_err_msgs = sizeof(err_msgs)/sizeof(err_msgs[0]);
46
gconf_strerror (GConfError en)
48
g_return_val_if_fail (en < n_err_msgs, NULL);
50
return _(err_msgs[en]);
54
gconf_error_quark (void)
56
static GQuark err_q = 0;
59
err_q = g_quark_from_static_string ("gconf-error-quark");
65
gconf_error_new_valist(GConfError en, const gchar* fmt, va_list args)
70
orig = g_strdup_vprintf(fmt, args);
72
err = g_error_new (GCONF_ERROR, en, "%s:\n %s",
82
gconf_error_new(GConfError en, const gchar* fmt, ...)
88
err = gconf_error_new_valist(en, fmt, args);
95
gconf_set_error (GError** err, GConfError en, const gchar* fmt, ...)
103
/* Warn if we stack up errors on top
104
* of each other. Keep the "deepest"
107
g_return_if_fail(*err == NULL);
109
va_start (args, fmt);
110
obj = gconf_error_new_valist(en, fmt, args);
116
/* This function should die. */
118
gconf_compose_errors (GError* err1, GError* err2)
120
if (err1 == NULL && err2 == NULL)
122
else if (err1 == NULL)
123
return g_error_copy(err2);
124
else if (err2 == NULL)
125
return g_error_copy(err1);
130
n = g_error_new (GCONF_ERROR, GCONF_ERROR_FAILED, " ");
132
if (err1->code == err2->code)
133
n->code = err1->code;
135
n->code = GCONF_ERROR_FAILED;
139
n->message = g_strconcat(err1->message, "\n", err2->message, NULL);