This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-16
Channels
- # babashka (17)
- # calva (35)
- # clerk (31)
- # cljs-dev (3)
- # clojars (1)
- # clojure (16)
- # clojure-europe (4)
- # clojurescript (38)
- # clojutre (2)
- # cursive (8)
- # datomic (16)
- # exercism (5)
- # fulcro (5)
- # gratitude (3)
- # hyperfiddle (55)
- # joyride (1)
- # lsp (40)
- # off-topic (6)
- # portal (64)
- # practicalli (1)
- # reitit (3)
- # releases (1)
- # shadow-cljs (38)
- # sql (1)
- # tools-deps (8)
- # xtdb (9)
I'm using what I think is a standard set of reitit middleware:
[;; query-params & form-params
parameters/parameters-middleware
;; content-negotiation
ring-muuntaja/format-negotiate-middleware
;; encoding response body
ring-muuntaja/format-response-middleware
;; exception handling
exception/exception-middleware
;; decoding request body
ring-muuntaja/format-request-middleware
;; coercing response bodys
rrc/coerce-response-middleware
;; coercing request parameters
rrc/coerce-request-middleware
;; multipart
multipart/multipart-middleware]
The exception/exception-middleware
is needed to catch 400
bad request responses, i.e., when coercion of incoming parameters fail. However, it also catches exceptions that would be turned into a 500
response. For example if my response does not comply with the schema for the route or if there is an actual exception triggered in my code. In these cases, I want a full stack trace in my terminal. So whenever I get a 500
response, I disable the exception middleware to see the response. Is there a way to configure exception/exception-middleware
to only catch 400
errors?Yep, please check this out https://github.com/metosin/reitit/blob/master/doc/ring/exceptions.md#exceptioncreate-exception-middleware
I will, thanks!