Hey all. I have the following code:
But this results in breaking the webpage with an
(try [] (catch :default e [:div "Default content"]))
Uncaught Error: Invalid arity: 0error. 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.
You could also use
[(throw (ex-msg "BOOM!"))] instead of
[] if you’re just trying to exercise your try/catch. See also the
I'll try the react error boundary, thanks!
Works like a charm, thanks!1👍