1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-errors.c Error reporting
4 * Copyright (C) 2002 Red Hat Inc.
6 * Licensed under the Academic Free License version 1.2
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "dbus-errors.h"
26 * @defgroup DBusErrors Error reporting
28 * @brief Error reporting
30 * Types and functions related to reporting errors.
33 * In essence D-BUS error reporting works as follows:
36 * DBusResultCode result = DBUS_RESULT_SUCCESS;
37 * dbus_some_function (arg1, arg2, &result);
38 * if (result != DBUS_RESULT_SUCCESS)
39 * printf ("an error occurred\n");
46 * Set a result code at a result code location,
47 * if code_address is not #NULL.
49 * @param code_address place to store the result code.
50 * @param code the result code itself.
53 dbus_set_result (DBusResultCode *code_address,
61 * Returns a string describing the given result code.
63 * @param code the result code to describe.
64 * @returns a constant string describing the code.
67 dbus_result_to_string (DBusResultCode code)
69 /* This is a switch to the compiler will complain if we
70 * aren't handling some codes
74 case DBUS_RESULT_SUCCESS:
76 case DBUS_RESULT_FAILED:
77 return "Unknown error";
78 case DBUS_RESULT_NO_MEMORY:
79 return "Not enough memory available";
80 case DBUS_RESULT_IO_ERROR:
81 return "Error reading or writing data";
82 case DBUS_RESULT_BAD_ADDRESS:
83 return "Could not parse address";
84 case DBUS_RESULT_NOT_SUPPORTED:
85 return "Feature not supported";
86 case DBUS_RESULT_LIMITS_EXCEEDED:
87 return "Resource limits exceeded";
88 case DBUS_RESULT_ACCESS_DENIED:
89 return "Permission denied";
90 case DBUS_RESULT_AUTH_FAILED:
91 return "Could not authenticate to server";
92 case DBUS_RESULT_NO_SERVER:
94 case DBUS_RESULT_TIMEOUT:
95 return "Connection timed out";
96 case DBUS_RESULT_NO_NETWORK:
97 return "Network unavailable";
98 case DBUS_RESULT_ADDRESS_IN_USE:
99 return "Address already in use";
100 case DBUS_RESULT_DISCONNECTED:
101 return "Disconnected.";
103 /* no default, it would break our compiler warnings */
106 return "Invalid error code";