1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser 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 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser 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.
21 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GLib Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GLib at ftp://ftp.gtk.org/pub/gtk/.
30 g_error_new_valist(GQuark domain,
37 error = g_new (GError, 1);
39 error->domain = domain;
41 error->message = g_strdup_vprintf (format, args);
47 g_error_new (GQuark domain,
55 g_return_val_if_fail (format != NULL, NULL);
56 g_return_val_if_fail (domain != 0, NULL);
58 va_start (args, format);
59 error = g_error_new_valist (domain, code, format, args);
66 g_error_new_literal (GQuark domain,
72 g_return_val_if_fail (message != NULL, NULL);
73 g_return_val_if_fail (domain != 0, NULL);
75 err = g_new (GError, 1);
79 err->message = g_strdup (message);
85 g_error_free (GError *error)
87 g_return_if_fail (error != NULL);
89 g_free (error->message);
95 g_error_copy (const GError *error)
99 g_return_val_if_fail (error != NULL, NULL);
101 copy = g_new (GError, 1);
105 copy->message = g_strdup (error->message);
111 g_error_matches (const GError *error,
116 error->domain == domain &&
121 g_set_error (GError **err,
133 g_warning ("GError set over the top of a previous GError or uninitialized memory.\n"
134 "This indicates a bug in someone's code. You must ensure an error is NULL before it's set.");
136 va_start (args, format);
137 *err = g_error_new_valist (domain, code, format, args);
142 g_clear_error (GError **err)