This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-18
Channels
- # announcements (4)
- # aws (24)
- # babashka (118)
- # babashka-sci-dev (18)
- # beginners (56)
- # calva (2)
- # clojure (54)
- # clojure-dev (8)
- # clojure-europe (25)
- # clojure-gamedev (5)
- # clojure-nl (1)
- # clojure-norway (6)
- # clojure-uk (2)
- # conjure (1)
- # core-async (1)
- # data-science (3)
- # datomic (5)
- # emacs (8)
- # fulcro (4)
- # hyperfiddle (12)
- # interop (1)
- # jackdaw (4)
- # lsp (5)
- # mid-cities-meetup (5)
- # nbb (32)
- # off-topic (21)
- # reitit (5)
- # shadow-cljs (12)
- # sql (8)
- # vim (18)
- # xtdb (9)
any news on that? https://github.com/metosin/reitit/issues/420 Im having some super strange behaviour when passing an invalid body, instead of getting a 400 Im not even able to intercept the exception when making a request
I’m not a Pedestal expert but I could figure out that the exception/exception-interceptor
is not compatible with Pedestal exception handling. It doesn’t know how to pick up the error from :io.pedestal.interceptor.chain/error
key in ctx
.
I tried replacing the exception interceptor with something like this
{:error (fn [ctx ex]
(assoc ctx :response {:status 400
:body "error horror"}))}
and it worked as one would expect. Pedestal exception fn is described in http://pedestal.io/reference/error-handling
ex
contains the exception caught by Pedestal wrapped into ex-info. You could decide based on the exception what to return.
I hope this helps you forward building a more robust error handler.
We could and probably should improve the pedestal module by adding a working error handler. However I at least need to get more familiar with Pedestal.. Or we wait for Tommi to come back from holidays. 🙂 Also PR’s are warmly welcome!Im trying to see if I can fix this
but the error appears to be at reitit.http.coercion/coerce-request
thats what the stacktrace is telling me
I tried to modify exception/exception-interceptor to check for :io.pedestal.interceptor.chain/error in the ctx but the error happens before that
hey @U055NJ5CC sorry to ping you on this, but could you point me to a place in the code so I can try to open a PR fixing it? right now its impossible to use pedestal + spec + reitit
@U3QUAHZJ6 @U6N4HSMFW I am facing same exception when I try to reitit.coercion.specs
with pedestal and reitit. The problem is not in pedestal or reitit the problem is in muuntaja/format-response-interceptor
interceptor. Basically muuntaja/encodes
(used inside format-response-interceptor) doesn't know how to serialise reitit.coercion.spec
class. The trace in exception
"No serializer found for class clojure.spec.alpha$map_spec_impl$reify__1997"
confirms that.
The quick and easy workaround I found is to replace reitit.coercion.spec
with reitit.coercion.malli
(for validation) . Then everything works as expected.