22 #include "opensync_internals.h" 45 case OSYNC_ERROR_GENERIC:
46 return "UnknownError";
47 case OSYNC_ERROR_IO_ERROR:
49 case OSYNC_ERROR_NOT_SUPPORTED:
50 return "NotSupported";
51 case OSYNC_ERROR_TIMEOUT:
53 case OSYNC_ERROR_DISCONNECTED:
54 return "Disconnected";
55 case OSYNC_ERROR_FILE_NOT_FOUND:
56 return "FileNotFound";
58 return "UnspecifiedError";
72 if (!error || !format)
79 memset(buffer, 0,
sizeof(buffer));
81 g_vsnprintf(buffer, 1024, format, args);
83 (*error)->message = g_strdup(buffer);
84 (*error)->type = type;
107 osync_return_val_if_fail(error != NULL, NULL);
109 return osync_error_name_from_type(OSYNC_NO_ERROR);
110 return osync_error_name_from_type((*error)->type);
120 osync_return_if_fail(error != NULL);
124 if ((*error)->message)
125 g_free ((*error)->message);
160 return OSYNC_NO_ERROR;
161 return (*error)->type;
174 return (*error)->message;
189 osync_return_if_fail(error != NULL);
190 osync_return_if_fail(*error != NULL);
193 va_start(args, format);
196 memset(buffer, 0,
sizeof(buffer));
197 g_vsnprintf(buffer, 1024, format, args);
199 g_free((*error)->message);
200 (*error)->message = g_strdup(buffer);
225 (*target)->message = g_strdup((*source)->message);
226 (*target)->type = (*source)->type;
241 va_start(args, format);
257 (*error)->type = type;
void osync_error_duplicate(OSyncError **target, OSyncError **source)
Duplicates the error into the target.
osync_bool osync_error_is_set(OSyncError **error)
Checks if the error is set.
OSyncErrorType
Defines the possible error types.
void osync_error_set_vargs(OSyncError **error, OSyncErrorType type, const char *format, va_list args)
Sets a error from a va_list.
void osync_error_free(OSyncError **error)
Frees the error so it can be reused.
const char * osync_error_get_name(OSyncError **error)
This will return a string describing the type of the error.
void osync_error_set_type(OSyncError **error, OSyncErrorType type)
Sets the type of an error.
void osync_error_update(OSyncError **error, const char *format,...)
Updates the error message.
OSyncErrorType osync_error_get_type(OSyncError **error)
Returns the type of the error.
void osync_error_set(OSyncError **error, OSyncErrorType type, const char *format,...)
Sets the error.
const char * osync_error_print(OSyncError **error)
Returns the message of the error.