This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-04
Channels
- # announcements (30)
- # aws (7)
- # babashka (7)
- # beginners (64)
- # calva (39)
- # cherry (17)
- # cider (1)
- # clj-on-windows (6)
- # clojure (30)
- # clojure-austin (12)
- # clojure-europe (25)
- # clojure-nl (2)
- # clojure-norway (23)
- # clojure-spec (23)
- # clojure-uk (6)
- # clojurescript (20)
- # cursive (18)
- # datahike (3)
- # datalevin (12)
- # datomic (9)
- # etaoin (5)
- # graalvm (45)
- # instaparse (2)
- # interceptors (11)
- # kaocha (1)
- # lsp (102)
- # meander (6)
- # nbb (16)
- # off-topic (30)
- # pathom (83)
- # pedestal (6)
- # portal (5)
- # re-frame (12)
- # reitit (5)
- # rewrite-clj (10)
- # scittle (35)
- # shadow-cljs (49)
- # spacemacs (10)
- # vim (14)
Hi folks, I am trying to integrate reitit
with pedestal
web backend. For some reason coercion/coerce-exceptions-interceptor
is not handling coercion
type exceptions.
Code:
(def router
(http/router ["/v1"
["/" {:get {:summary "simple get handler"
:parameters {:query {:student-id s/Int}}
:handler home-page}
:post {:summary "simple post handler"
:responses {200 {:body {:total s/Int}}}
:parameters {:body {:name s/Str :age s/Int}}
:handler home-page}}]]
{:exception pretty/exception
:data {:muuntaja m/instance
:compile rc/compile-request-coercers
:coercion reitit.coercion.schema/coercion
:interceptors [(parameters/parameters-interceptor)
(muuntaja/format-negotiate-interceptor)
(muuntaja/format-response-interceptor)
(muuntaja/format-request-interceptor)
(muuntaja/format-interceptor)
(coercion/coerce-response-interceptor)
(coercion/coerce-request-interceptor)
(coercion/coerce-exceptions-interceptor)
(exception/exception-interceptor)]}}))
exception:
ERROR i.p.http.impl.servlet-interceptor - {:msg "Dev interceptor caught an exception; Forwarding it as the response.", :line 314}
clojure.lang.ExceptionInfo: clojure.lang.ExceptionInfo in Interceptor :reitit.http.coercion/coerce-request - Request coercion failed: #reitit.coercion.CoercionError{:schema {:student-id Int, Keyword Any}, :errors {:student-id missing-required-key}}
at io.pedestal.interceptor.chain$throwable__GT_ex_info.invokeStatic(chain.clj:35)
at io.pedestal.interceptor.chain$throwable__GT_ex_info.invoke(chain.clj:32)
at io.pedestal.interceptor.chain$try_f.invokeStatic(chain.clj:57)
at io.pedestal.interceptor.chain$try_f.invoke(chain.clj:44)
at io.pedestal.interceptor.chain$process_all_with_binding.invokeStatic(chain.clj:171)
at io.pedestal.interceptor.chain$process_all_with_binding.invoke(chain.clj:146)
at io.pedestal.interceptor.chain$process_all$fn__9181.invoke(chain.clj:188)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:665)
at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1973)
at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1973)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at io.pedestal.interceptor.chain$process_all.invokeStatic(chain.clj:186)
at io.pedestal.interceptor.chain$process_all.invoke(chain.clj:182)
at io.pedestal.interceptor.chain$enter_all.invokeStatic(chain.clj:235)
at io.pedestal.interceptor.chain$enter_all.invoke(chain.clj:229)
at io.pedestal.interceptor.chain$execute.invokeStatic(chain.clj:379)
at io.pedestal.interceptor.chain$execute.invoke(chain.clj:352)
at io.pedestal.interceptor.chain$execute.invokeStatic(chain.clj:389)
at io.pedestal.interceptor.chain$execute.invoke(chain.clj:352)
at io.pedestal.http.impl.servlet_interceptor$interceptor_service_fn$fn__12805.invoke(servlet_interceptor.clj:351)
at io.pedestal.http.servlet.FnServlet.service(servlet.clj:28)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:550)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1434)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1349)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server.Server.handle(Server.java:516)
at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:400)
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:645)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:392)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
at
at
at
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: clojure.lang.ExceptionInfo: Request coercion failed: #reitit.coercion.CoercionError{:schema {:student-id Int, Keyword Any}, :errors {:student-id missing-required-key}}
at reitit.coercion$request_coercion_failed_BANG_.invokeStatic(coercion.cljc:46)
at reitit.coercion$request_coercion_failed_BANG_.invoke(coercion.cljc:44)
at reitit.coercion$request_coercer$fn__15954.invoke(coercion.cljc:86)
at reitit.coercion$coerce_request$fn__15967.invoke(coercion.cljc:113)
at clojure.lang.PersistentArrayMap.kvreduce(PersistentArrayMap.java:377)
at clojure.core$fn__8437.invokeStatic(core.clj:6845)
at clojure.core$fn__8437.invoke(core.clj:6830)
at clojure.core.protocols$fn__8167$G__8162__8176.invoke(protocols.clj:175)
at clojure.core$reduce_kv.invokeStatic(core.clj:6856)
at clojure.core$reduce_kv.invoke(core.clj:6847)
at reitit.coercion$coerce_request.invokeStatic(coercion.cljc:111)
at reitit.coercion$coerce_request.invoke(coercion.cljc:110)
at reitit.http.coercion$coerce_request_interceptor$fn__310$fn__312.invoke(coercion.cljc:24)
at io.pedestal.interceptor.chain$try_f.invokeStatic(chain.clj:54)
... 41 common frames omitted
Possibly related..? https://clojurians.slack.com/archives/C7YF1SBT3/p1658154595687229
Hi. I wanted to use a multimethod but it seems it's not supported?
Execution error (ExceptionInfo) at reitit.exception/exception (exception.cljc:19).
No implementation of method: :expand of protocol: #'reitit.core/Expand found for class: clojure.lang.MultiFn
fixed by wrapping like {:handler foobar}