util errors: add ErrUnauthorized

This commit is contained in:
Simone Gotti 2019-05-13 14:20:31 +02:00
parent 4a8d86ae76
commit 8331c43a18
1 changed files with 19 additions and 0 deletions

View File

@ -112,3 +112,22 @@ func IsErrForbidden(err error) bool {
_, ok := err.(*ErrForbidden) _, ok := err.(*ErrForbidden)
return ok return ok
} }
// ErrUnauthorized represent an error caused by an unauthorized request
// it's used to differentiate an internal error from an user error
type ErrUnauthorized struct {
Err error
}
func (e *ErrUnauthorized) Error() string {
return e.Err.Error()
}
func NewErrUnauthorized(err error) *ErrUnauthorized {
return &ErrUnauthorized{Err: err}
}
func IsErrUnauthorized(err error) bool {
_, ok := err.(*ErrUnauthorized)
return ok
}