Fork me on GitHub
#reitit
<
2023-04-16
>
DrLjótsson15:04:54

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 500response. 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?

DrLjótsson17:04:42

I will, thanks!