]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
cli: fix crash on wrong server base url (#25497)
authormarcoStocchi <redacted>
Fri, 10 Jul 2026 09:52:20 +0000 (11:52 +0200)
committerGitHub <redacted>
Fri, 10 Jul 2026 09:52:20 +0000 (11:52 +0200)
* llama-cli: fix crash on wrong server base url by catching exceptions and graceful exit

* review: leaner catch group: json error and standard exception

tools/cli/cli-context.cpp

index 74d60eb19df4696e1a63d0f24fe05b84c1d3eead..0de8f69025ce89c64fc482146f6454bde2c85465 100644 (file)
@@ -153,9 +153,19 @@ bool cli_context::init() {
 
     if (use_external_server) {
         spinner.reset();
-        if (!list_and_ask_models()) {
+        try {
+            if (!list_and_ask_models()) {
+                return false;
+            }
+        } catch (const json::parse_error & e) {
+            ui::show_error(e.what());
+            ui::show_message("This might be caused by an incorrect server-base endpoint URL");
+            return false;
+        } catch (const std::exception & e) {
+            ui::show_error(e.what());
             return false;
         }
+
         // restore the spinner for the next step
         spinner.emplace("Waiting for server...");
     }