-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patherrors.go
More file actions
34 lines (26 loc) · 855 Bytes
/
errors.go
File metadata and controls
34 lines (26 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package dauth
import "errors"
type ErrInvalidAuthentication struct {
inner error
}
func (e *ErrInvalidAuthentication) Error() string {
return e.inner.Error()
}
func (e *ErrInvalidAuthentication) Unwrap() error {
return e.inner
}
func NewErrInvalidAuthentication(inner error) error {
if inner == nil {
return nil
}
return &ErrInvalidAuthentication{inner: inner}
}
var (
ErrAuthorizationHeaderNotFound = NewErrInvalidAuthentication(errors.New("no authorization header found"))
ErrAuthorizationHeaderMissingBearer = NewErrInvalidAuthentication(errors.New("authorization header format must be Bearer {token}"))
)
// IsErrInvalidAuthentication checks whether the provided error is of type ErrInvalidAuthentication.
func IsErrInvalidAuthentication(err error) bool {
var target *ErrInvalidAuthentication
return errors.As(err, &target)
}