This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-25
Channels
- # announcements (30)
- # beginners (4)
- # calva (173)
- # cider (22)
- # clj-kondo (12)
- # clojure-austin (2)
- # clojure-brasil (1)
- # clojure-europe (56)
- # clojure-korea (1)
- # clojure-nl (1)
- # clojure-norway (53)
- # clojure-uk (5)
- # clojurescript (25)
- # data-science (82)
- # hyperfiddle (87)
- # introduce-yourself (11)
- # jobs-discuss (44)
- # malli (4)
- # off-topic (7)
- # pedestal (8)
- # re-frame (16)
- # releases (1)
- # shadow-cljs (41)
- # slack-help (5)
- # sql (1)
- # squint (1)
hey folks! I'm trying to learn more about pedestal and error-handling, but I'm unsure on how to use it, on the pedestal documentation there is a sample code: http://pedestal.io/pedestal/0.6/reference/error-handling.html#_error_dispatch_interceptor which I think already returns an interceptor, but when trying to use it, what should I do which ctx and ex values? my editor complains about unresolved symbols
In Pedestal 0.7 (still alpha) there's a clj-kondo file that explains to the linter what to do here.
Essentailly, error-dispatch
is defining an interceptor and a :error callback function in the interceptor, and uses your two symbols, so if you (temporarily) map error-dispatch to be the same as defn (that's something you can do in Cursive) then you should see the warnings go away.
However, I generally believe that exception handling should occur inside the interceptors themselves; once an exception escapes from an interceptor's own logic, it feels patchy to try to handle it elsewhere, if it's a recoverable error (rather than sometihng unrecoverable like OutOfMemoryError).
place your cursor on error-dispatch
, click on the yellow bulb and select "resolve macro as... " and choose clojure.core/fn
It should make the cursive/kondo be happy on simple cases
Btw, you can do (def service-error-handler (interceptor/interceptor {:name ::another-bad-one :error (fn [ctx ex] ...)))}))
. I think that using a function is way simpler, and avoid wired core.match exceptions
thanks @U04VDKC4G and @U2J4FRT2T !!