From 0105a07695fe2b57701dd7fe722296b0bf8944db Mon Sep 17 00:00:00 2001 From: Bram Schoenmakers Date: Sun, 24 Dec 2023 08:53:59 +0100 Subject: [PATCH] Do some error handling whenever curl fails --- kagi.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kagi.el b/kagi.el index 932e9d0..24867af 100644 --- a/kagi.el +++ b/kagi.el @@ -151,7 +151,12 @@ PROMPT is used to fill in the POST part of the request." (let ((command (kagi--build-curl-command prompt))) (if kagi-debug kagi--canned-response - (shell-command-to-string command)))) + + (with-temp-buffer + (let ((return (call-process-shell-command command nil t))) + (if (eql return 0) + (buffer-string) + (error "Call to FastGPT API returned with status %s" return))))))) (defun kagi--process-prompt (prompt) "Submit a PROMPT to FastGPT and process the API response.