uiri / SEGIMAP

IMAP (and LMTP) Server written in Rust
MIT License
32 stars 6 forks source link

Implement Proper Error Handling #15

Closed indiv0 closed 7 years ago

indiv0 commented 9 years ago

Per the discussion in #3, simply using unwrap() on all Results and Options isn't good practice or very sustainable, in terms of code-debt.

Currently, our preferred error-handling system is to use our own Error struct by using match statements to manually unwrap values and wrap external errors in our custom Error type.

This results in overly verbose statements and (occaisionally) repeated code for error wrapping.

We can reduce the necessity of said unwrappings by replacing them with the try! macro. This can be done by implementing the FromError trait for our custom error type.

Additonally, per the error docs, error messages should be handled by the Display trait.

As such, it is probably best to remove the desc field from our Error struct and handle error messages via an implementation of the Display trait.

However, in that scenario, our Error struct is then only a custom implementation of the standard Error trait described in the the error chaining RFC and later expanded upon in the error documentation above. Taking this into consideration, it's probably best to replace our Error struct with an Error enum (as seen in libraries such as rustc-serialize).

This is in our best interest because it removes the redundant and unnecessary Error struct, allows for easier error message handling (by simply adding a string::String parameter to the enum values which require it), and for simpler internal error representation and generation.

Tasks

indiv0 commented 9 years ago

Work on this issue is being done on the error_handling branch.

indiv0 commented 7 years ago

Silly Github, I said "not close #15".

uiri commented 7 years ago

Closed by #24