4 ms·
I use exactly that way of error handling and I find it scales very very well and makes refactoring a breeze. Nothing stops you from defining certain "borders"
by valenterry 3y ago
I use exactly that way of error handling and I find it scales very very well and makes refactoring a breeze.
Nothing stops you from defining certain "borders" in your application where you wrap errors into something meaningful. E.g. if I write a file-IO library, I will return a custom "CannotOpenFile" error in my public methods which will encapsulate the underlying error(s) instead of returning a list of potential low-level errors had caused it.
The difference is that with uniontypes it is me who decides the level of abstraction and granularity, whereas without it, I'm forced into manually handling errors types pretty much everywhere.
Rust is an example where you are always forced to either align error types or where you lose information about what kind of errors it could be by using a more abstract error type. (which is the last thing you mentioned)
- foldr 3y ago> I use exactly that way of error handling and I find it scales very very well and makes refactoring a breeze. The enormous number of Rust crates that attempt to automate various aspects of defining error types suggests that not everyone finds it so pleasant.
- valenterry 3y agoPlease read my post again, especially the last part...
- foldr 3y agoI have read your post. Apologies if I’ve misunderstood it, but just replying in that way doesn’t really help.
- valenterry 3y agoI'm confused because I didn't say that Rust makes refactoring a breeze right? In fact, I said it does the opposite. So I don't really understand your response.
- foldr 3y agoAh, I read "I use exactly that way of error handling..." as "I use exactly that way of error handling [in Rust]..." (given the post you were replying to), but I guess you were talking about Zig. Sorry for the misunderstanding.
- valenterry 3y agoHaha, I'm actually using neither Rust nor Zig and I think both don't support the way of error-handling that I described. No worries, happens. :)