hyperfiddle

oλv 2025-06-10T10:21:25.709049Z

I was clicking around a bit in the tutorial and then it seemed to crash 🤔 This happened yesterday too

oλv 2025-06-10T10:22:32.187349Z

Geoffrey Gaillard 2025-06-10T14:47:04.986599Z

Sorry about the crash. Fixed. Thank you :)

oλv 2025-06-10T15:31:11.243599Z

Great, thank you!

2025-06-10T11:20:53.616179Z

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?

oλv 2025-06-10T11:22:51.417989Z

You can do your try/catch in regular clj(s) code

2025-06-10T11:25:25.763999Z

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?

oλv 2025-06-10T11:27:28.269829Z

Yes, anywhere where the issue is exposed by throwing exceptions :^)

2025-06-10T11:29:39.002369Z

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. 🙂

2025-06-10T11:30:34.466209Z

I might not be aware that something might throw an exception.

xificurC 2025-06-10T11:38:01.693909Z

exceptions should surface in the browser or REPL console. I understand you find this lacking, can you clarify what functionality would fulfill your needs?

2025-06-10T11:41:29.986559Z

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.

👀 1
2025-06-10T11:42:40.748169Z

Perhaps also log that something unexpected happened.

xificurC 2025-06-10T11:54:16.498219Z

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 ;)

xificurC 2025-06-10T12:03:35.237319Z

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

2025-06-10T12:22:21.186349Z

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.

Dustin Getz (Hyperfiddle) 2025-06-10T12:33:55.768409Z

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

Dustin Getz (Hyperfiddle) 2025-06-10T12:35:16.815269Z

we agree with the request for an unmatched error catchall in userland to display an error page

2025-06-10T13:01:21.897579Z

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