Would it make sense to add an Unwrap() function to this library? I have a usecase where I need to check the type of the underlying error, which (AFAICS) Is() cannot do. I can access the Err field of an errors.Error, but that requires having a *Error instead of an error, which AFAIU isn't the intended way to return (wrapped) errors.
Such a function could simply look like:
func Unwrap(err error) error {
switch e := err.(type) {
case *errors.Error:
return e.Err
default:
return err
}
}
Would it make sense to add an
Unwrap()
function to this library? I have a usecase where I need to check the type of the underlying error, which (AFAICS)Is()
cannot do. I can access theErr
field of anerrors.Error
, but that requires having a*Error
instead of anerror
, which AFAIU isn't the intended way to return (wrapped) errors.Such a function could simply look like: