I was clicking around a bit in the tutorial and then it seemed to crash 🤔 This happened yesterday too
Sorry about the crash. Fixed. Thank you :)
Great, thank you!
If there’s an error in my app that causes an exception to be thrown, I can end up with a blank UI and an error in the js console. I know v3 doesn’t have try/catch, so how should I handle this?
You can do your try/catch in regular clj(s) code
If I understand, then that would be anywhere I think there might be an issue? drop to clj(s) code in specific places? What if I wanted something equivalent to a try/catch at the top level of my app?
Yes, anywhere where the issue is exposed by throwing exceptions :^)
OK. FWIW, I think it might be useful to be able to have a global catch-all exception handler for things in my app that I don’t understand. 🙂
I might not be aware that something might throw an exception.
exceptions should surface in the browser or REPL console. I understand you find this lacking, can you clarify what functionality would fulfill your needs?
I would like to let the user know that something went wrong rather than displaying a blank UI. So I think what I would like is some way of detecting in my code that some random exception occurred, so that I can display an error message.
Perhaps also log that something unexpected happened.
I see. The pattern we use for this today is roughly
• we capture user events (form submit, button click, ..) as data and collect it upwards the call stack, together with the token
• there's a transactor loop at the top that translates the data to an effect and returns [:ok v] or [:failed msg]
• we send the failure back with the token (`(spend msg)`). Now the UI can show it
Speaking more generally, there's 2 kinds of errors, expected and unexpected. The expected ones will need special handling code anyway. The unexpected ones today crash the application. Another thing on our todo list ;)
the https://electric.hyperfiddle.net/tutorial/token_explainer has the simplest example of this. The offloaded fn could use a try/catch. The form explainer coming after is a more advanced example
Thanks. I'll take a look at those explainers in the next few days. In dev, I've sometimes had uncaught exceptions on initial load in the browser when old data in local storage is no longer in the right form for the app. I'm guessing that tokens wouldn't help with that. Anyway, thanks and I will read up and have a think.
tokens model remote transactions, to deal with shape conflicts i think you want try/catch inside the clojure functions that are reading/parsing from storage
we agree with the request for an unmatched error catchall in userland to display an error page
> i think you want try/catch inside the clojure functions that are reading/parsing from storage Yes, makes sense > we agree with the request for an unmatched error catchall in userland to display an error page Great.