News for hackers. Stuff that matters.
Re:Why Go's Error Handling Is Awesome by arp242 on Tuesday July 07, 2020 @09:48AM (#23759204)
You should never match against "err.Error()" for conditional error handling, a better solution is to use a custom error type. There are a bunch of different ways to approach this in Go.
Re:Why Go's Error Handling Is Awesome by julvo on Tuesday July 07, 2020 @09:56AM (#23759292)
Ah that's better, thanks. here a link for others who are reading this https://gobyexample.com/errors
Re:Why Go's Error Handling Is Awesome by apta on Tuesday July 07, 2020 @06:06PM (#23764646)
Except most libraries do nothing of the sort, so you end up having to do a substring search.
Re:Why Go's Error Handling Is Awesome by arp242 on Tuesday July 07, 2020 @09:24PM (#23766061)
I've rarely run in to this, but if you do then I'd expect most people will be happy to accept a PR.