update: add custom error for unloaded pool info

This commit is contained in:
ngn 2024-07-13 14:23:39 +03:00
parent ba992d395d
commit 4ea2d22519
4 changed files with 11 additions and 2 deletions

View File

@ -138,6 +138,7 @@ typedef enum lm_error {
LM_ERR_HashDigestFail = 130,
LM_ERR_FileHashFail = 131,
LM_ERR_FileHashNoMatch = 132,
LM_ERR_InfoNotLoaded = 133,
} lm_error_t;
typedef struct lm_error_desc {

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-13 14:11+0300\n"
"POT-Creation-Date: 2024-07-13 14:22+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -582,3 +582,8 @@ msgstr ""
#, c-format
msgid "file hash does not match for %s"
msgstr ""
#: src/error.c:158
#, fuzzy
msgid "pool info is not loaded"
msgstr "URL hostname is too large"

View File

@ -77,8 +77,10 @@ size_t lm_ctx_sync(lm_ctx_t *ctx, bool do_update, lm_ctx_sync_callback_t callbac
cbdata.pool = cur;
cbdata.state = SYNC_DOWNLOADING_LIST;
if(!cur->loaded)
if(!cur->loaded){
lm_error_set(LM_ERR_InfoNotLoaded);
goto next_list;
}
if(lm_pool_path_is_empty(cur)){
pdebug(__func__, "(%s) failed to load list, pool paths are empty", cur->name);

View File

@ -155,6 +155,7 @@ void lm_error_set(lm_error_t code, ...) {
{.code = LM_ERR_HashDigestFail, .desc = _("failed create digest for hashing") },
{.code = LM_ERR_FileHashFail, .desc = _("failed to get hash of %s: %s") },
{.code = LM_ERR_FileHashNoMatch, .desc = _("file hash does not match for %s") },
{.code = LM_ERR_InfoNotLoaded, .desc = _("pool info is not loaded") },
};
char *fmt = NULL;