From d4a871d7694ca98f6108279b19cee482acc3705e Mon Sep 17 00:00:00 2001 From: cage Date: Sun, 12 Mar 2023 11:42:55 +0100 Subject: [PATCH] - [gemini] returned the meta header to user when a protocol error occurred. --- src/gemini/client.lisp | 13 +++++++++---- src/gui/client/main-window.lisp | 3 ++- src/gui/server/public-api-gemini-stream.lisp | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gemini/client.lisp b/src/gemini/client.lisp index 792e857..d8a1f6e 100644 --- a/src/gemini/client.lisp +++ b/src/gemini/client.lisp @@ -228,12 +228,16 @@ :reader error-code) (error-description :initarg :error-description - :reader error-description)) + :reader error-description) + (meta + :initarg :meta + :reader meta)) (:report (lambda (condition stream) (format stream - (_ "The server responded with the error ~a: ~s") + (_ "The server responded with the error ~a (~a): ~a") (error-code condition) - (error-description condition)))) + (error-description condition) + (meta condition)))) (:documentation "The condition signalled for error codes (i.e. 4x and 5x)")) (define-condition gemini-tofu-error (error) @@ -345,7 +349,8 @@ (let ((response-code (find-code-class status-code))) (error 'gemini-protocol-error :error-code (code response-code) - :error-description (description response-code)))) + :error-description (description response-code) + :meta meta))) ;; ((header-not-implemented-p parsed-header) ;; (error 'conditions:not-implemented-error ;; :text (_ "The server requested a certificate but client validation is not implemented by this program"))) diff --git a/src/gui/client/main-window.lisp b/src/gui/client/main-window.lisp index e59d836..29b0843 100644 --- a/src/gui/client/main-window.lisp +++ b/src/gui/client/main-window.lisp @@ -486,7 +486,8 @@ ((or (gemini-client:header-temporary-failure-p status-code) (gemini-client:header-permanent-failure-p status-code) (gemini-client:header-certificate-failure-p status-code)) - (error (_ "Error connecting to: ~a:~2%~a") iri status-description)) + (error (_ "~a ~a Error connecting to: ~a:~2%~a") + status-code status-description iri meta)) ((gemini-client:header-redirect-p status-code) (when (gui:ask-yesno (format nil (_ "Follow redirection to ~a?") meta) :title (_ "Redirection") diff --git a/src/gui/server/public-api-gemini-stream.lisp b/src/gui/server/public-api-gemini-stream.lisp index d2125c7..12f435b 100644 --- a/src/gui/server/public-api-gemini-stream.lisp +++ b/src/gui/server/public-api-gemini-stream.lisp @@ -213,7 +213,7 @@ (gemini-client:gemini-protocol-error (e) (make-gemini-response (gemini-client:error-code e) (gemini-client:error-description e) - "" + (gemini-client:meta e) url)) (error (e) (error (_ "Error getting ~s: ~a") url e))