Home | History | Annotate | Download | only in dbus

Lines Matching full:error

2 /* dbus-errors.c Error reporting
32 * @defgroup DBusErrorInternals Error reporting internals
34 * @brief Error reporting internals
43 char *name; /**< error name */
44 char *message; /**< error message */
58 * Returns a longer message describing an error name.
59 * If the error name is unknown, returns the name
62 * @param error the error to describe
63 * @returns a constant string describing the error.
66 message_from_error (const char *error)
68 if (strcmp (error, DBUS_ERROR_FAILED) == 0)
69 return "Unknown error";
70 else if (strcmp (error, DBUS_ERROR_NO_MEMORY) == 0)
72 else if (strcmp (error, DBUS_ERROR_IO_ERROR) == 0)
73 return "Error reading or writing data";
74 else if (strcmp (error, DBUS_ERROR_BAD_ADDRESS) == 0)
76 else if (strcmp (error, DBUS_ERROR_NOT_SUPPORTED) == 0)
78 else if (strcmp (error, DBUS_ERROR_LIMITS_EXCEEDED) == 0)
80 else if (strcmp (error, DBUS_ERROR_ACCESS_DENIED) == 0)
82 else if (strcmp (error, DBUS_ERROR_AUTH_FAILED) == 0)
84 else if (strcmp (error, DBUS_ERROR_NO_SERVER) == 0)
86 else if (strcmp (error, DBUS_ERROR_TIMEOUT) == 0)
88 else if (strcmp (error, DBUS_ERROR_NO_NETWORK) == 0)
90 else if (strcmp (error, DBUS_ERROR_ADDRESS_IN_USE) == 0)
92 else if (strcmp (error, DBUS_ERROR_DISCONNECTED) == 0)
94 else if (strcmp (error, DBUS_ERROR_INVALID_ARGS) == 0)
96 else if (strcmp (error, DBUS_ERROR_NO_REPLY) == 0)
98 else if (strcmp (error, DBUS_ERROR_FILE_NOT_FOUND) == 0)
101 return error;
107 * @defgroup DBusErrors Error reporting
109 * @brief Error reporting
114 * In essence D-Bus error reporting works as follows:
117 * DBusError error;
118 * dbus_error_init (&error);
119 * dbus_some_function (arg1, arg2, &error);
120 * if (dbus_error_is_set (&error))
122 * fprintf (stderr, "an error occurred: %s\n", error.message);
123 * dbus_error_free (&error);
128 * so callers who don't care about the error can ignore it.
130 * There are some rules. An error passed to a D-Bus function must
131 * always be unset; you can't pass in an error that's already set. If
132 * a function has a return code indicating whether an error occurred,
133 * and also a #DBusError parameter, then the error will always be set
134 * if and only if the return code indicates an error occurred. i.e.
135 * the return code and the error are never going to disagree.
137 * An error only needs to be freed if it's been set, not if
140 * You can check the specific error that occurred using
155 * the error only needs to be freed if it is set at some point.
157 * @param error the DBusError.
160 dbus_error_init (DBusError *error)
164 _dbus_return_if_fail (error != NULL);
168 real = (DBusRealError *)error;
177 * Frees an error that's been set (or just initialized),
178 * then reinitializes the error as in dbus_error_init().
180 * @param error memory where the error is stored.
183 dbus_error_free (DBusError *error)
187 _dbus_return_if_fail (error != NULL);
189 real = (DBusRealError *)error;
197 dbus_error_init (error);
201 * Assigns an error name and message to a DBusError. Does nothing if
202 * error is #NULL. The message may be #NULL, which means a default
206 * Because this function does not copy the error name or message, you
210 * @param error the error.or #NULL
211 * @param name the error name (not copied!!!)
212 * @param message the error message (not copied!!!)
215 dbus_set_error_const (DBusError *error,
221 _dbus_return_if_error_is_set (error);
224 if (error == NULL)
227 _dbus_assert (error->name == NULL);
228 _dbus_assert (error->message == NULL);
233 real = (DBusRealError *)error;
241 * Moves an error src into dest, freeing src and
243 * src is reinitialized to an empty error. dest may not
244 * contain an existing error. If the destination is
245 * #NULL, just frees and reinits the source error.
247 * @param src the source error
248 * @param dest the destination error or #NULL
267 * Checks whether the error is set and has the given
269 * @param error the error
271 * @returns #TRUE if the given named error occurred
274 dbus_error_has_name (const DBusError *error,
277 _dbus_return_val_if_fail (error != NULL, FALSE);
280 _dbus_assert ((error->name != NULL && error->message != NULL) ||
281 (error->name == NULL && error->message == NULL));
283 if (error->name != NULL)
286 _dbus_string_init_const (&str1, error->name);
295 * Checks whether an error occurred (the error is set).
297 * @param error the error object
298 * @returns #TRUE if an error occurred
301 dbus_error_is_set (const DBusError *error)
303 _dbus_return_val_if_fail (error != NULL, FALSE);
304 _dbus_assert ((error->name != NULL && error->message != NULL) ||
305 (error->name == NULL && error->message == NULL));
306 return error->name != NULL;
310 * Assigns an error name and message to a DBusError.
311 * Does nothing if error is #NULL.
315 * idea, just go ahead and provide a useful error message. It won't
318 * If no memory can be allocated for the error message,
319 * an out-of-memory error message will be set instead.
321 * @param error the error.or #NULL
322 * @param name the error name
326 dbus_set_error (DBusError *error,
335 if (error == NULL)
339 _dbus_return_if_error_is_set (error);
342 _dbus_assert (error->name == NULL);
343 _dbus_assert (error->message == NULL);
368 real = (DBusRealError *)error;
389 _DBUS_SET_OOM (error);