News for hackers. Stuff that matters.
Re:Go 2 Draft Designs by lclarkmichalek on Tuesday August 28, 2018 @02:22PM (#17861388)
This is something I don't enjoy about Rust's error handling. The context is added on a package level (or at least, the level at which the Error type is defined, which seems to be usually package level), and often quite far away from where the error was emitted. For all its ills, `errors.Wrap(err, "...")` puts the adding of context incredibly close to the place where the error is relevant.
Re:Go 2 Draft Designs by edflsafoiewq on Tuesday August 28, 2018 @04:17PM (#17862476)
x? will convert the error type for x, E1, to the error type for the calling function, E2, only when a conversion from E1 to E2 is defined. If its not possible to do this conversion without some contextual information, then this bare conversion can't be defined and x? will not compile. In that case, callers will have to do something like

    x.context(...)?
    x.map_err(|e| ...)?
    ...etc...
so they have to provide contextual information.
Re:Go 2 Draft Designs by IshKebab on Tuesday August 28, 2018 @04:56PM (#17862799)
You can use map_err or the failure crate's with_context to add context.
Re:Go 2 Draft Designs by cpuguy83 on Tuesday August 28, 2018 @04:05PM (#17862379)
What do you think are the ills of errors.Wrap?