Re:Announcing Rust 1.13
by ameliaquining on Thursday November 10, 2016 @06:44PM
(#12925827)
You often won't need to change the error object from what foo() returns; Rust errors are generally structs or enums, rather than non-machine-readable strings. But if you do need to change it, it looks like this:
[ Parent
| on HN ]
go errors are generally backed by structs as well (though not necessarily), even `fmt.Errorf("some error")` is a struct (called `errorString`).
`Error() string` is just the interface that things that want to be errors must implement, which ideally gives you the human readable version of the error.