4 ms·
I still am wondering how error handling should be done in pony, it only tells you an error has happend, not what has caused it or what kind of error happend.
by Asmod4n 6y ago
I still am wondering how error handling should be done in pony, it only tells you an error has happend, not what has caused it or what kind of error happend.
- spooneybarger 6y ago`error` in Pony is for partial functions. A partial function is where you can't compute a result based on the input. If you need to know what went wrong (because more than one thing might have gone wrong and that needs to be communicated), you can use a union type for the result and match accordingly (as you would in Rust as an example).
- Asmod4n 6y agoAh, i see. The files package does that apperently, correct? But cannot find it in the net package for example.
- ergl 6y agoOccasional Pony committer here. You're right, and improving how errors are handled for socket operations has been in my mind for a while. If you have used it and have any ideas on what you'd like to see there, feel free to drop by Zulip!
- spooneybarger 6y agoThe files package in general uses `error` and isn't very helpful in letting you know what went wrong. "Makes the files package better" is something that has been on a "list of things to improve" for a long time.
- andolanra 6y agoI tried using Pony for 2019's Advent of Code, and I ran into this problem. I ended up writing a whole blog post about the way that I tackled error-handling, which I don't think is the solution (especially since the Pony team is looking at new ways of expressing error-handling) but was sufficient for the programs I was writing: https://journal.infinitenegativeutility.com/pony-errors-and-logging https://journal.infinitenegativeutility.com/pony-errors-and-...