From 4ea2d2251901e64e908165c0ae066b1441b9e9f5 Mon Sep 17 00:00:00 2001 From: ngn Date: Sat, 13 Jul 2024 14:23:39 +0300 Subject: [PATCH] update: add custom error for unloaded pool info --- include/error.h | 1 + locale/tr/LC_MESSAGES/libmp.po | 7 ++++++- src/ctx/sync.c | 4 +++- src/error.c | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/error.h b/include/error.h index d7981ec..cb5a5e8 100644 --- a/include/error.h +++ b/include/error.h @@ -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 { diff --git a/locale/tr/LC_MESSAGES/libmp.po b/locale/tr/LC_MESSAGES/libmp.po index b37b73e..c0be8fe 100644 --- a/locale/tr/LC_MESSAGES/libmp.po +++ b/locale/tr/LC_MESSAGES/libmp.po @@ -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 \n" "Language-Team: LANGUAGE \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" diff --git a/src/ctx/sync.c b/src/ctx/sync.c index 222fa5c..5226422 100644 --- a/src/ctx/sync.c +++ b/src/ctx/sync.c @@ -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); diff --git a/src/error.c b/src/error.c index d55899d..b8f6925 100644 --- a/src/error.c +++ b/src/error.c @@ -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;