This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-05
Channels
- # announcements (16)
- # babashka (10)
- # beginners (80)
- # calva (18)
- # cider (10)
- # clojure (96)
- # clojure-austin (1)
- # clojure-europe (52)
- # clojure-france (6)
- # clojure-germany (2)
- # clojure-italy (4)
- # clojure-nl (4)
- # clojure-seattle (3)
- # clojure-spec (4)
- # clojure-uk (25)
- # clojurescript (97)
- # community-development (2)
- # cursive (7)
- # datomic (13)
- # figwheel-main (5)
- # fulcro (13)
- # inf-clojure (1)
- # jobs (3)
- # off-topic (33)
- # pathom (10)
- # polylith (8)
- # re-frame (7)
- # reitit (8)
- # releases (1)
- # reveal (2)
- # ring (4)
- # ring-swagger (1)
- # sci (6)
- # shadow-cljs (102)
- # slack-help (1)
- # spacemacs (28)
- # tools-deps (9)
- # vim (1)
- # xtdb (3)
Hey all. I have the following code:
(try
[[]]
(catch :default e
[:div "Default content"]))
But this results in breaking the webpage with an Uncaught Error: Invalid arity: 0
error. Is there any way to catch this so teh the "default content" string is shown?[[]]
doesn't throw - you cannot use try/catch here.
What throws is some Reagent/React machinery, waaaay down the line.
You can try using React's error boundaries that are supported by Reagent.
https://github.com/reagent-project/reagent/blob/master/doc/ReactFeatures.md#error-boundaries
You could also use [(throw (ex-msg "BOOM!"))]
instead of [[]]
if you’re just trying to exercise your try/catch. See also the js/window.onerror
property.