diff --git a/include/igloo/error.h b/include/igloo/error.h index 01267d5..48f3eb8 100644 --- a/include/igloo/error.h +++ b/include/igloo/error.h @@ -40,8 +40,24 @@ typedef struct { const char *description; } igloo_error_desc_t; -#define igloo_ERROR_GENERIC ((igloo_error_t)-1) -#define igloo_ERROR_NONE ((igloo_error_t)0) +#define igloo_ERROR_GENERIC ((igloo_error_t)-1) /* Generic error: A generic error occurred. */ +#define igloo_ERROR_NONE ((igloo_error_t)0) /* No error: The operation succeeded. */ + +#define igloo_ERROR_FAULT ((igloo_error_t)1) /* Invalid address */ +#define igloo_ERROR_INVAL ((igloo_error_t)2) /* Invalid argument */ +#define igloo_ERROR_BUSY ((igloo_error_t)3) /* Device or resource busy */ +#define igloo_ERROR_AGAIN ((igloo_error_t)4) /* Try again later */ +#define igloo_ERROR_NOMEM ((igloo_error_t)5) /* Not enough space: Memory allocation failed. */ +#define igloo_ERROR_NOENT ((igloo_error_t)6) /* Node does not exist: File, directory, object, or node does not exist. */ +#define igloo_ERROR_EXIST ((igloo_error_t)7) /* Node exists: Object, or node already exists. */ +#define igloo_ERROR_PERM ((igloo_error_t)8) /* Operation not permitted */ +#define igloo_ERROR_CONNECTED ((igloo_error_t)9) /* Already connected: The operation can not be completed while object is connected. */ +#define igloo_ERROR_UNCONNECTED ((igloo_error_t)10) /* Unconnected: The operation can not be completed while object is not connected. */ +#define igloo_ERROR_IO ((igloo_error_t)11) /* Input/output error */ +#define igloo_ERROR_CANNOTCONNECT ((igloo_error_t)12) /* Can not connect: Can not connect to remote resource. */ +#define igloo_ERROR_NOLOGIN ((igloo_error_t)13) /* Can not login: Can not log into service. */ +#define igloo_ERROR_NOTSECURE ((igloo_error_t)14) /* Connection, or object not secure: Connection, or object is not on required security level. */ +#define igloo_ERROR_BADCERT ((igloo_error_t)15) /* Bad certificate */ const igloo_error_desc_t * igloo_error_get_description(igloo_error_t error); const igloo_error_desc_t * igloo_error_getbyname(const char *name); diff --git a/src/error.c b/src/error.c index 5cde25f..f5c338f 100644 --- a/src/error.c +++ b/src/error.c @@ -17,18 +17,102 @@ #define ERROR_BASE(x) .error = igloo_ERROR_ ## x, .name = # x +// grep '^#define igloo_ERROR_' include/igloo/error.h | sed 's/^#define igloo_ERROR_\([^ ]*\) \+[^ ]\+ */\1::/; s/::\/\* \+\([^:]\+\): \+\(.\+\) \+\*\//:\1:\2/; s/::\/\* \+\([^:]\+\) \+\*\//:\1:/' | while IFS=: read name message description; do uuid=$(uuid -v 5 c4ce7102-4f5b-4421-9fb7-adbb299e336e "$name"); p=' '; printf "$p{\n$p${p}ERROR_BASE(%s),\n" "$name"; [ -n "$message" ] && printf "$p$p.message = \"%s\",\n" "$message"; [ -n "$description" ] && printf "$p$p.description = \"%s\",\n" "$description"; printf "$p$p.uuid = \"%s\"\n$p},\n" "$uuid"; done | sed '$s/,$//' static const igloo_error_desc_t __desc[] = { { ERROR_BASE(GENERIC), - .uuid = "953b7275-21f3-4697-8d30-33f346f9833e", .message = "Generic error", - .description = "A generic error occurred." + .description = "A generic error occurred.", + .uuid = "4f4dfebc-0b86-51e7-8233-73ff1c4707cf" }, { ERROR_BASE(NONE), - .uuid = "4fa39862-0647-46ea-bfdf-fd2a5c7f6e9d", .message = "No error", - .description = "The operation succeeded." + .description = "The operation succeeded.", + .uuid = "3f9fa7d9-3d35-5358-bfa4-0c708bc2d7c9" + }, + { + ERROR_BASE(FAULT), + .message = "Invalid address", + .uuid = "92ef9c60-654f-550d-a256-dc80a85ba0a0" + }, + { + ERROR_BASE(INVAL), + .message = "Invalid argument", + .uuid = "1146a208-c6aa-59be-93c5-e8c431e48892" + }, + { + ERROR_BASE(BUSY), + .message = "Device or resource busy", + .uuid = "5d867873-72ba-569c-bf62-f9c784b9ef3f" + }, + { + ERROR_BASE(AGAIN), + .message = "Try again later", + .uuid = "8b8d4d4b-ff8f-53e0-ad82-aa4d15a4c64b" + }, + { + ERROR_BASE(NOMEM), + .message = "Not enough space", + .description = "Memory allocation failed.", + .uuid = "3c236243-fb2e-5f63-a8ff-255a496ff998" + }, + { + ERROR_BASE(NOENT), + .message = "Node does not exist", + .description = "File, directory, object, or node does not exist.", + .uuid = "0bd73191-c0a8-5a60-8986-590aad6f937c" + }, + { + ERROR_BASE(EXIST), + .message = "Node exists", + .description = "Object, or node already exists.", + .uuid = "2f763d4f-3bd9-5a2a-a5bd-c9da14b721bd" + }, + { + ERROR_BASE(PERM), + .message = "Operation not permitted", + .uuid = "bd371bfb-1e55-5819-aeb5-e8a085e287cf" + }, + { + ERROR_BASE(CONNECTED), + .message = "Already connected", + .description = "The operation can not be completed while object is connected.", + .uuid = "eeabbbd0-ac81-5eb5-ac77-6e474bc6caee" + }, + { + ERROR_BASE(UNCONNECTED), + .message = "Unconnected", + .description = "The operation can not be completed while object is not connected.", + .uuid = "7c2e9838-add7-5d2f-8b7a-ba04924075f7" + }, + { + ERROR_BASE(IO), + .message = "Input/output error", + .uuid = "25541978-3f69-5d63-bd06-c86e299d8f10" + }, + { + ERROR_BASE(CANNOTCONNECT), + .message = "Can not connect", + .description = "Can not connect to remote resource.", + .uuid = "3f507c9c-e30b-5c81-91aa-e7c3a21bf3f6" + }, + { + ERROR_BASE(NOLOGIN), + .message = "Can not login", + .description = "Can not log into service.", + .uuid = "6fcaf080-dfaf-5ab0-a800-9d67d2d9c64f" + }, + { + ERROR_BASE(NOTSECURE), + .message = "Connection, or object not secure", + .description = "Connection, or object is not on required security level.", + .uuid = "393bc752-cb40-5781-b6ce-c23ccc3c46b0" + }, + { + ERROR_BASE(BADCERT), + .message = "Bad certificate", + .uuid = "07bbfd3a-d432-55b0-a294-a99278e6fa04" } };