News for hackers. Stuff that matters.
Re:Eris – A better way to handle, trace, and log errors in Go by andrepd on Wednesday December 25, 2019 @06:17PM (#21881036)
Rust has a postfix `?` operator to propagate errors up the call stack.
Re:Eris – A better way to handle, trace, and log errors in Go by awinter-py on Wednesday December 25, 2019 @06:26PM (#21881064)
as I understand it, this requires an Option or Result return type that matches the type of the statement

The ? operator is better than nothing, but I still need my error types to match all the way up the stack

Re:Eris – A better way to handle, trace, and log errors in Go by dnpp123 on Wednesday December 25, 2019 @08:02PM (#21881402)
AFAIK if you properly define the From/To operator, rust generates it for you.

And if you think about it, defining those operator is a good practice as it tells your program how to handle errors.

Re:Eris – A better way to handle, trace, and log errors in Go by status_quo69 on Wednesday December 25, 2019 @09:10PM (#21881654)
Or you can use a boxed error iirc. Matching on the type of error after you do that isn't exactly great but it's doable if all you want to do is bubble the error up.

Places where that approach really sucks include web api routes (unless I haven't figured out a trick yet). For example, rocket defines Responder on Result so long as the ok and error variants both define it, but since a boxed error is erased it doesn't function correctly.

Re:Eris – A better way to handle, trace, and log errors in Go by onei on Thursday December 26, 2019 @04:32AM (#21882775)
You can use the Error trait [1] from the stdlib, implement it for your error types and then just use the trait in your Result. That way you don't need the types to match and you can convert between then as needed while adding the previous errors to the chain.

1. https://doc.rust-lang.org/std/error/trait.Error.html

Re:Eris – A better way to handle, trace, and log errors in Go by awinter-py on Thursday December 26, 2019 @11:10AM (#21884723)
ah thanks
Re:Eris – A better way to handle, trace, and log errors in Go by weberc2 on Wednesday December 25, 2019 @06:49PM (#21881145)
It doesn’t require it. Instead it could just generate the same error handling boilerplate. But I think it would be a mistake versus general purpose (generic) sum types a la Rust.