From 36b6345c01e25570a693403f32847dc336e3bcd6 Mon Sep 17 00:00:00 2001 From: shrrrriya_ Date: Sat, 3 Jan 2026 10:08:05 +0200 Subject: [PATCH] kiwix-manage: improve error messages for failed operations --- src/manager/kiwix-manage.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/manager/kiwix-manage.cpp b/src/manager/kiwix-manage.cpp index 2022d38..2ad8e14 100644 --- a/src/manager/kiwix-manage.cpp +++ b/src/manager/kiwix-manage.cpp @@ -46,10 +46,10 @@ void show(const kiwix::Library& library, const std::string& bookId) << "mediaCount:\t" << book.getMediaCount() << std::endl << "size:\t\t" << book.getSize() << " KB" << std::endl; } catch (std::out_of_range&) { - std::cout << "No book " << bookId << " in the library" << std::endl; + std::cout << "No book with ID '" << bookId << "' found in the library" << std::endl; } std::cout << std::endl; -} +}i // Older version of docopt doesn't declare Options. Let's declare it ourself. using Options = std::map; @@ -128,9 +128,13 @@ int handle_add(kiwix::LibraryPtr library, const std::string& libraryPath, } if (manager.addBookFromPathAndGetId(zimPath, zimPathToSave, url, false).empty()) { - std::cerr << "Cannot add ZIM " << zimPath << " to the library." << std::endl; - return 1; - } + std::cerr << "Cannot add ZIM " << zimPath << " to the library." << std::endl; + std::cerr << "This may happen if:" << std::endl; + std::cerr << " - The file does not exist" << std::endl; + std::cerr << " - The file is not readable" << std::endl; + std::cerr << " - The file is not a valid ZIM file" << std::endl; + return 1; +} } return 0;