This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-11
Channels
- # adventofcode (33)
- # babashka (1)
- # beginners (11)
- # biff (3)
- # calva (2)
- # cider (24)
- # clj-kondo (9)
- # cljfx (5)
- # clojure (39)
- # clojure-austin (2)
- # clojure-europe (11)
- # clojure-nl (1)
- # clojure-norway (22)
- # clojure-uk (10)
- # community-development (18)
- # data-science (24)
- # datahike (3)
- # events (3)
- # hyperfiddle (11)
- # lsp (22)
- # malli (3)
- # matrix (1)
- # off-topic (24)
- # other-languages (3)
- # overtone (7)
- # pathom (5)
- # reitit (2)
- # shadow-cljs (34)
- # sql (20)
- # squint (13)
does anyone use reitit with coercion on the frontend? The behavior in reitit.frontend.history
calls reitit.frontend/match-by-path
which https://github.com/metosin/reitit/blob/620d0c271175a4e11d91d922b26c8162660db3f9/modules/reitit-frontend/src/reitit/frontend.cljs#L63C30-L63C34 if coercion fails. If I try to wrap the router in a try catch then using {:href (rfe/href nme),,,
fails because there is no history. I don't see how this is usable for a client-side app as uncaught exceptions cause the page to crash. Any ideas? I guess I can just coerce in on-navigate on my own using data in the route.
Solved it by copying the implementation of reitit.coercion/request-coercer
and commenting out the throw
call:
(defn request-coercer [coercion type model {::keys [extract-request-format parameter-coercion serialize-failed-result]
:or {extract-request-format reitit.coercion/extract-request-format-default
parameter-coercion reitit.coercion/default-parameter-coercion}}]
(if coercion
(if-let [{:keys [keywordize? open? in style]} (parameter-coercion type)]
(let [transform (comp (if keywordize? walk/keywordize-keys identity) in)
model (if open? (reitit.coercion/-open-model coercion model) model)]
(if-let [coercer (reitit.coercion/-request-coercer coercion style model)]
(fn [request]
(let [value (transform request)
format (extract-request-format request)
result (coercer value format)]
(if (reitit.coercion/error? result)
result
;(request-coercion-failed! result coercion value in request serialize-failed-result)
result))))))))
would be awesome if this could be parameterized when creating the frontend router