|
|
|
|
|
by svnpenn
1542 days ago
|
|
> What's the difference between importing some hundred's of lines from thiserror in rust vs importing the "error" package in go? Again, you're comparing apples and oranges. It seems you didn't see my previous
example, here it is again: type errorString string
func (e errorString) Error() string {
return string(e)
}
|
|
Yes, your example implements the error interface, but it's not realistic. There is real go code that does that, but that's the reason I have to do string-matching type error handling in go, and frankly it's an argument against the language that its error handling is such a mess that some people see that as reasonable.
Having code that does
is something you can do, sure, but it's not good code. Idiomatically in go, it would also be "errors.New", not this errorString type you made.In rust, that would also be just as easy since it would be:
using anyhow, which is the de-facto standard way to do crappy string-style erroring, like the above.But that's not what I want to talk about since that sort of error handling isn't interesting in either language, and isn't where they differ.