Error handling - per method enum

Coming from Java background I'm used to methods having a list of exceptions they can throw. In Rust there seems to be a practice of creating a single MyError enum and reusing it across the application. Therfore, when pattern-matching on the result one has to "handle" all the MyError enum variants even if only one or two can actually be returned from that method.

Am I missunderstanding something?

You can by all means create different error types for different functions.

1 Like