/
error.go
54 lines (46 loc) · 1.63 KB
/
error.go
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
package warp
import "fmt"
//Error represents an error in a WebAuthn relying party operation
type Error struct {
err string
wrapped error
}
//Error implements the error interface
func (e Error) Error() string {
return e.err
}
//Unwrap allows for error unwrapping
func (e Error) Unwrap() error {
return e.wrapped
}
//Wrap returns a new error which contains the provided error wrapped with this
//error
func (e Error) Wrap(err error) Error {
n := e
n.wrapped = err
return n
}
//Is establishes equality for error types
func (e Error) Is(target error) bool {
return e.Error() == target.Error()
}
//NewError returns a new Error with a custom message
func NewError(fmStr string, els ...interface{}) Error {
return Error{
err: fmt.Sprintf(fmStr, els...),
}
}
//Categorical top-level errors
var (
ErrDecodeAttestedCredentialData = Error{err: "Error decoding attested credential data"}
ErrDecodeAuthenticatorData = Error{err: "Error decoding authenticator data"}
ErrDecodeCOSEKey = Error{err: "Error decoding raw public key"}
ErrGenerateChallenge = Error{err: "Error generating challenge"}
ErrOption = Error{err: "Option error"}
ErrNotImplemented = Error{err: "Not implemented"}
ErrVerifyAttestation = Error{err: "Error verifying attestation"}
ErrVerifyAuthentication = Error{err: "Error verifying authentication"}
ErrVerifyClientExtensionOutput = Error{err: "Error verifying client extension output"}
ErrVerifyRegistration = Error{err: "Error verifying registration"}
ErrVerifySignature = Error{err: "Error verifying signature"}
)