multiformats / rust-multiaddr

multiaddr implementation in rust
https://crates.io/crates/multiaddr
Other
86 stars 45 forks source link

Improve error handling #2

Closed dignifiedquire closed 3 years ago

progval commented 8 years ago

What improvements do you want to do?

dignifiedquire commented 8 years ago

Not sure, I am still very new to rust and unsure of tgr best way for a library to handle and expose errors.

progval commented 8 years ago

I asked earlier at #rust-fr how people do it; someone answered that most of the time we create an enum to use as the Err part of a Result. They also told me libraries exist to avoid this boilerplate, but I don't think we need it for now (not many error sources).

I think here we could just use Result<blah, String>, and return Err(format!{"{:?"}, error_from_nom */ }) most of the time, and an enum otherwise. eg. for decapsulate: enum DecapsulateError { ParseError(String), ProtocolNotFound }.

mxinden commented 3 years ago

I am closing here as (a) the discussion has stalled and (b) I would say error handling is in a good state. Please comment in case you think otherwise.