-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
65 lines (51 loc) · 1.24 KB
/
errors.go
File metadata and controls
65 lines (51 loc) · 1.24 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package mack
import (
"errors"
"fmt"
)
type Error string
func (e Error) Error() string {
return string(e)
}
const (
ErrPredicateNotSatisfied = Error("macaroon: predicate not satisfied")
ErrVerificationFailed = Error("macaroon: verification failed")
ErrInvalidArgument = Error("macaroon: invalid argument")
)
type predicateNotSatisfiedError struct {
predicate Predicate
}
func (m *predicateNotSatisfiedError) Error() string {
return fmt.Sprintf("%s: %v", ErrPredicateNotSatisfied, m.predicate)
}
func (m *predicateNotSatisfiedError) Predicate() Predicate {
return m.predicate
}
func (m *predicateNotSatisfiedError) Is(err error) bool {
return errors.Is(err, ErrPredicateNotSatisfied)
}
type verificationError struct {
macaroon *Macaroon
err error
}
func (m *verificationError) Error() string {
return string(ErrVerificationFailed)
}
func (m *verificationError) Macaroon() *Macaroon {
return m.macaroon
}
func (m *verificationError) Is(err error) bool {
if errors.Is(err, ErrVerificationFailed) {
return true
}
return errors.Is(m.err, err)
}
func (m *verificationError) Unwrap() error {
return m.err
}
func validationError(m *Macaroon, err error) error {
return &verificationError{
macaroon: m,
err: err,
}
}