News for hackers. Stuff that matters.
Re:Guide to Error Handling in Rust by shepmaster on Sunday August 25, 2024 @12:08PM (#41348383)
I partially agree. I have been experimenting with creating a lot of small error types (e.g. one per function) because of the benefit of narrowing down the set of possible causes. I also dislike crate-wide errors for the same reason.

However, having an anonymous sum type isn’t a good solution here because there’s nowhere for you to add context to. It’s not useful for your final error to say “permission denied” without the context of a file name, or knowing that you were trying to open configuration file, etc.

There are no comments on this comment yet.