#include "../include/error.h" #include "../include/util.h" #include lm_error_t error = LM_ERR_NoError; void lm_error_set(lm_error_t code) { error = code; } char *lm_strerror() { lm_error_desc_t errors[] = { {.code = LM_ERR_NoError, .desc = _("no error") }, {.code = LM_ERR_URLBadChar, .desc = _("URL contains an invalid character") }, {.code = LM_ERR_URLBadProtocol, .desc = _("URL does not have a valid protocol field") }, {.code = LM_ERR_URLTooLarge, .desc = _("URL is too large") }, {.code = LM_ERR_URLHostLarge, .desc = _("URL hostname is too large") }, {.code = LM_ERR_URLPathLarge, .desc = _("URL path is too large") }, {.code = LM_ERR_URLBadHost, .desc = _("URL does not have a valid hostname") }, {.code = LM_ERR_URLBadPath, .desc = _("URL does not have a valid path") }, {.code = LM_ERR_URLBadPort, .desc = _("URL does not contain a hostname with a valid port number")}, {.code = LM_ERR_URLPortUnknown, .desc = _("URL protocol port number is unknown") }, {.code = LM_ERR_URLEnd, .desc = _("URL is incomplete") }, {.code = LM_ERR_PoolNoSupport, .desc = _("pool does not support the specified protocol") }, }; for (int i = 0; i < sizeof(errors) / sizeof(lm_error_desc_t); i++) { if (errors[i].code == error) return errors[i].desc; } return NULL; } lm_error_t lm_error() { return error; }