kwrooijen 2021-02-05T13:55:37.035200Z

Hey all. I have the following code:

  (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?

p-himik 2021-02-05T14:12:01.037300Z

[[]] 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.


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.

kwrooijen 2021-02-05T14:16:15.038Z

I'll try the react error boundary, thanks!

borkdude 2021-02-05T14:16:19.038200Z

kwrooijen 2021-02-05T14:24:10.038400Z

Works like a charm, thanks!