Lines Matching refs:error
47 * DBusError error = DBUS_ERROR_INIT;
49 * do_things_with (&error);
55 * DBusError error;
57 * dbus_error_init (&error);
58 * do_things_with (&error);
67 char *name; /**< error name */
68 char *message; /**< error message */
84 * Returns a longer message describing an error name.
85 * If the error name is unknown, returns the name
88 * @param error the error to describe
89 * @returns a constant string describing the error.
92 message_from_error (const char *error)
94 if (strcmp (error, DBUS_ERROR_FAILED) == 0)
95 return "Unknown error";
96 else if (strcmp (error, DBUS_ERROR_NO_MEMORY) == 0)
98 else if (strcmp (error, DBUS_ERROR_IO_ERROR) == 0)
100 else if (strcmp (error, DBUS_ERROR_BAD_ADDRESS) == 0)
102 else if (strcmp (error, DBUS_ERROR_NOT_SUPPORTED) == 0)
104 else if (strcmp (error, DBUS_ERROR_LIMITS_EXCEEDED) == 0)
106 else if (strcmp (error, DBUS_ERROR_ACCESS_DENIED) == 0)
108 else if (strcmp (error, DBUS_ERROR_AUTH_FAILED) == 0)
110 else if (strcmp (error, DBUS_ERROR_NO_SERVER) == 0)
112 else if (strcmp (error, DBUS_ERROR_TIMEOUT) == 0)
114 else if (strcmp (error, DBUS_ERROR_NO_NETWORK) == 0)
116 else if (strcmp (error, DBUS_ERROR_ADDRESS_IN_USE) == 0)
118 else if (strcmp (error, DBUS_ERROR_DISCONNECTED) == 0)
120 else if (strcmp (error, DBUS_ERROR_INVALID_ARGS) == 0)
122 else if (strcmp (error, DBUS_ERROR_NO_REPLY) == 0)
124 else if (strcmp (error, DBUS_ERROR_FILE_NOT_FOUND) == 0)
126 else if (strcmp (error, DBUS_ERROR_OBJECT_PATH_IN_USE) == 0)
129 return error;
142 * In essence D-Bus error reporting works as follows:
145 * DBusError error;
146 * dbus_error_init (&error);
147 * dbus_some_function (arg1, arg2, &error);
148 * if (dbus_error_is_set (&error))
150 * fprintf (stderr, "an error occurred: %s\n", error.message);
151 * dbus_error_free (&error);
156 * so callers who don't care about the error can ignore it.
158 * There are some rules. An error passed to a D-Bus function must
159 * always be unset; you can't pass in an error that's already set. If
160 * a function has a return code indicating whether an error occurred,
161 * and also a #DBusError parameter, then the error will always be set
162 * if and only if the return code indicates an error occurred. i.e.
163 * the return code and the error are never going to disagree.
165 * An error only needs to be freed if it's been set, not if
168 * You can check the specific error that occurred using
183 * the error only needs to be freed if it is set at some point.
185 * @param error the DBusError.
188 dbus_error_init (DBusError *error)
192 _dbus_return_if_fail (error != NULL);
196 real = (DBusRealError *)error;
205 * Frees an error that's been set (or just initialized),
206 * then reinitializes the error as in dbus_error_init().
208 * @param error memory where the error is stored.
211 dbus_error_free (DBusError *error)
215 _dbus_return_if_fail (error != NULL);
217 real = (DBusRealError *)error;
225 dbus_error_init (error);
229 * Assigns an error name and message to a DBusError. Does nothing if
230 * error is #NULL. The message may be #NULL, which means a default
234 * Because this function does not copy the error name or message, you
238 * @param error the error.or #NULL
239 * @param name the error name (not copied!!!)
240 * @param message the error message (not copied!!!)
243 dbus_set_error_const (DBusError *error,
249 _dbus_return_if_error_is_set (error);
252 if (error == NULL)
255 _dbus_assert (error->name == NULL);
256 _dbus_assert (error->message == NULL);
261 real = (DBusRealError *)error;
269 * Moves an error src into dest, freeing src and
271 * src is reinitialized to an empty error. dest may not
272 * contain an existing error. If the destination is
273 * #NULL, just frees and reinits the source error.
275 * @param src the source error
276 * @param dest the destination error or #NULL
295 * Checks whether the error is set and has the given
297 * @param error the error
299 * @returns #TRUE if the given named error occurred
302 dbus_error_has_name (const DBusError *error,
305 _dbus_return_val_if_fail (error != NULL, FALSE);
308 _dbus_assert ((error->name != NULL && error->message != NULL) ||
309 (error->name == NULL && error->message == NULL));
311 if (error->name != NULL)
314 _dbus_string_init_const (&str1, error->name);
323 * Checks whether an error occurred (the error is set).
325 * @param error the error object
326 * @returns #TRUE if an error occurred
329 dbus_error_is_set (const DBusError *error)
331 _dbus_return_val_if_fail (error != NULL, FALSE);
332 _dbus_assert ((error->name != NULL && error->message != NULL) ||
333 (error->name == NULL && error->message == NULL));
334 return error->name != NULL;
338 * Assigns an error name and message to a DBusError.
339 * Does nothing if error is #NULL.
343 * idea, just go ahead and provide a useful error message. It won't
346 * If no memory can be allocated for the error message,
347 * an out-of-memory error message will be set instead.
349 * @param error the error.or #NULL
350 * @param name the error name
354 dbus_set_error (DBusError *error,
363 if (error == NULL)
367 _dbus_return_if_error_is_set (error);
370 _dbus_assert (error->name == NULL);
371 _dbus_assert (error->message == NULL);
398 real = (DBusRealError *)error;
419 _DBUS_SET_OOM (error);