branch: elpa/gptel
commit 8195d2f4a1a6de73ddbd8593ce7667c541ad713c
Author: Karthik Chikmagalur <[email protected]>
Commit: Karthik Chikmagalur <[email protected]>
gptel: Handle non-string API error messages
* gptel.el (gptel--handle-error): If the API returns a null error
type and/or message, handle it without errors and include it in
the error output. (#1156)
---
gptel.el | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/gptel.el b/gptel.el
index 21f67118a9d..c869f259ec8 100644
--- a/gptel.el
+++ b/gptel.el
@@ -1178,9 +1178,11 @@ Perform UI updates and run post-response hooks."
(if (stringp error-data)
(message "%s error: (%s) %s" backend-name http-msg (string-trim
error-data))
(when-let* ((error-type (plist-get error-data :type)))
- (setq http-msg (concat "(" http-msg ") " (string-trim error-type))))
+ (setq http-msg (concat "(" http-msg ") "
+ (string-trim (gptel--to-string error-type)))))
(when-let* ((error-msg (plist-get error-data :message)))
- (message "%s error: (%s) %s" backend-name http-msg (string-trim
error-msg))))
+ (message "%s error: (%s) %s" backend-name http-msg
+ (string-trim (gptel--to-string error-msg)))))
(if-let* ((gptel-window (get-buffer-window gptel-buffer 'visible)))
(with-selected-window gptel-window
(mapc (lambda (f) (funcall f (marker-position start-marker)