From 4cb4248c6c7655c51639c16afabfa0d2a778f530 Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 17 May 2024 18:07:33 -0700 Subject: Fix: better error handling --- src/protocol.lisp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/protocol.lisp b/src/protocol.lisp index 300195f..51c7211 100644 --- a/src/protocol.lisp +++ b/src/protocol.lisp @@ -26,6 +26,8 @@ :type (or nil (integer 100 599)))) (:documentation "Conditions signalled during the request handling protocol.")) +(defmethod status-code ((err error)) 500) + (define-condition cannot-authenticate (protocol-error) () (:default-initargs :status-code 401) (:documentation "Signalled when a endpoint's AUTHENTICATE method returns NIL, @@ -58,7 +60,7 @@ that the request has insufficient permissions to evoke the endpoint handler. ")) (defgeneric protocol-error-result (err) (:documentation "The content and mimetype to returned to the client having encountered an error.") - (:method ((err protocol-error)) (values nil nil))) + (:method ((err error)) (values nil nil))) (defun abort-on-error (err) "Assign a return code based on the type of error encountered and @@ -78,15 +80,10 @@ that the request has insufficient permissions to evoke the endpoint handler. ")) (defmethod http:acceptor-dispatch-request :around ((acceptor http:acceptor) request) (handler-case (call-next-method) - (protocol-error (err) - (if *debugging* - (invoke-debugger err) - (abort-on-error err))) - (error (err) (if *debugging* (invoke-debugger err) - (http:abort-request-handler))))) + (abort-on-error err))))) (defun protocol-error (error-class ep &rest kwargs) (apply #'error -- cgit v1.2.3