aboutsummaryrefslogtreecommitdiff
path: root/src/protocol.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/protocol.lisp')
-rw-r--r--src/protocol.lisp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/protocol.lisp b/src/protocol.lisp
index 51c7211..f94364a 100644
--- a/src/protocol.lisp
+++ b/src/protocol.lisp
@@ -42,9 +42,10 @@ that the request has insufficient permissions to evoke the endpoint handler. "))
((wrapped
:reader wrapped
:initarg :error
+ :initform nil
:documentation "A root error that may have caused this error to be signalled."))
(:default-initargs :status-code 400)
- (:documentation "Signalled when the body of a request cannot be deserialized."))
+ (:documentation "Signalled when the body of a request cannot be deserialized, for any reason.."))
(define-condition slot-required (protocol-error)
((mising-slot
@@ -159,3 +160,15 @@ AUTHORIZE while handling endpoint-class instance EP."
(defun get-cookie (name)
"Returns the cookie with name NAME the actively"
(http:cookie-in name))
+
+(define-condition request-error (error)
+ ((content :reader error-content :initarg :content :initform "Bad Request")
+ (mimetype :reader error-content-mimetype :initarg :mimetype :initform "text/plain")
+ (code :reader status-code :initarg :code :initform 400)))
+
+(defmethod protocol-error-result ((err request-error))
+ (values (error-content err) (error-content-mimetype err)))
+
+(defun err (&key (code 400) (content "Bad Request") (mimetype "text/plain"))
+ "Signal an error and abort request."
+ (error 'request-error :code code :content content :mimetype mimetype))