httpauth icon indicating copy to clipboard operation
httpauth copied to clipboard

Update error handling to use exported error types instead of relying on checking the string

Open flexd opened this issue 8 years ago • 0 comments

Checking the string is a very bad idea, and it is a much better idea to create exported error types, such as ErrorAlreadyAuthenticated that we can check for instead of relying on checking the string contents of err.Error(). err.Error() is for the user to read, not the machines.

http://dave.cheney.net/2016/04/27/dont-just-check-errors-handle-them-gracefully is a good read detailing how it's best to go about this. :-)

He is also involved in a package that follows the rules he suggests in the blogpost https://github.com/pkg/errors

flexd avatar May 10 '16 08:05 flexd