util errors: add ErrUnauthorized
This commit is contained in:
parent
4a8d86ae76
commit
8331c43a18
|
@ -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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue