Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



In Rust, I think it's more idiomatic to just implement the `Display` trait on you error type so that you can generate the string when you need it instead of at the time the error occurs




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: