|
|
|
|
|
by cube2222
2869 days ago
|
|
There's another one I often use: Create a custom error type, for example DB Error: type DBError struct {
Temporary bool
NetworkBased bool
Cause error
}
Now you can provide functions like IsTemporary(err).Otherwise, you can use 2# with a twist, instead of matching on a type, you can do: switch {
case isErrFetchForbidden(err):
case isErrFetchNotFound(err):
}
or even: IsBadRequest(err)
IsInternal(err)
IsTimeout(err)
|
|