aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2024-05-17 18:07:33 -0700
committercolin <colin@cicadas.surf>2024-05-17 18:07:33 -0700
commit4cb4248c6c7655c51639c16afabfa0d2a778f530 (patch)
treed68ec8009effea5afaa718981917e9c50d7091f9
parentb912459040ec0eea7a83df195c8aab7dd206296b (diff)
Fix: better error handling
-rw-r--r--src/protocol.lisp11
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