summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-02-18 12:32:21 -0600
committerColin Okay <okay@toyful.space>2022-02-18 12:32:21 -0600
commit92fe387b39d56f94e19d412c24a0c19a792f1ad1 (patch)
tree4b91e8094ae1f872084efb8b34ef412849cccdda
parent15572ea0f7613a94993c49b3ee2a58e90e560a9a (diff)
added http error handling to generated request-with macro
-rw-r--r--lazybones-client.asd2
-rw-r--r--lazybones-client.lisp9
2 files changed, 8 insertions, 3 deletions
diff --git a/lazybones-client.asd b/lazybones-client.asd
index 0c14785..2b69347 100644
--- a/lazybones-client.asd
+++ b/lazybones-client.asd
@@ -2,7 +2,7 @@
:description "Generate client functions for a LAZYBONES:APP instance"
:author "Colin Okay <okay@toyful.space>"
:license "AGPLv3"
- :version "0.1.5"
+ :version "0.2.0"
:serial t
:depends-on (#:lazybones)
:components ((:file "lazybones-client")))
diff --git a/lazybones-client.lisp b/lazybones-client.lisp
index f8aca87..8e215d6 100644
--- a/lazybones-client.lisp
+++ b/lazybones-client.lisp
@@ -46,7 +46,8 @@ header.
COOKIES should be an instance of CL-COOKIE:COOKIE-JAR. Defaults to
*COOKIES*.
\"
- (let ((content-type-var (gensym)))
+ (let ((content-type-var (gensym))
+ (http-error-var (gensym)))
`(let ((*host* (or ,host *host*))
(*body* (or ,body *body*))
(*headers* (or ,headers *headers*))
@@ -54,7 +55,11 @@ COOKIES should be an instance of CL-COOKIE:COOKIE-JAR. Defaults to
(,content-type-var ,content-type))
(when ,content-type-var
(push (cons \"Content-Type\" ,content-type-var) *headers*))
- ,@forms)))")
+ (handler-case (progn ,@forms)
+ (dex:http-request-failed (,http-error-var)
+ (format *error-output* \"~a -- ~a\"
+ (dex:response-status ,http-error-var)
+ (dex:response-body ,http-error-var)))))))")
(defun make-defun-name (method dispatch-pattern)
"Utility for making function names for endpoint request functions."