diff options
author | colin <colin@cicadas.surf> | 2024-05-17 18:07:33 -0700 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2024-05-17 18:07:33 -0700 |
commit | 4cb4248c6c7655c51639c16afabfa0d2a778f530 (patch) | |
tree | d68ec8009effea5afaa718981917e9c50d7091f9 /src | |
parent | b912459040ec0eea7a83df195c8aab7dd206296b (diff) |
Fix: better error handling
Diffstat (limited to 'src')
-rw-r--r-- | src/protocol.lisp | 11 |
1 files 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 |