3 ms·
I think I have read everything Dave Cheney has ever written about errors. But you misunderstand what I'm saying. The standard library is already littered with
by fauigerzigerk 10y ago
I think I have read everything Dave Cheney has ever written about errors. But you misunderstand what I'm saying.
The standard library is already littered with error values defined on the package level. Many third party packages emulate that approach.
Once you have done that in package, there is no way to change it. You cannot add function call specific data to an error after the fact. There is no way to implement an IsTemporary(error) function once you have clients that compare any returned error to a package level singleton using ==.
>Knowing the exact error code is probably not what a caller wants
I had that need many times. For instance, I needed to get the SQLSTATE from database errors. There is a huge number of SQLSTATE codes and interpreting/classifying them can't be the job of a data access package or even a DBMS specific driver library.
Also, how would a networking package know what I consider temporary? Some protocols like HTTP specify some errors to be temporary, but that may not coincide with what I'm willing to retry or not retry.