-
Notifications
You must be signed in to change notification settings - Fork 51
/
errors.go
36 lines (31 loc) · 1.32 KB
/
errors.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
package tokens
import (
"errors"
"fmt"
)
// Custom errors used by this package.
var (
ErrTokenTooSmall = errors.New("randomize: token is small")
ErrTokenEncodeFailed = errors.New("unable to encode token")
ErrTokenHashFailed = errors.New("unable to hash token")
ErrTokenSignFailed = errors.New("unable to sign token")
ErrSharedSecretMissing = errors.New("secret not found")
ErrInvalidSecret = errors.New("invalid secret")
ErrInvalidTokenLength = errors.New("not enough data")
ErrMissingSignature = errors.New("signature is missing")
ErrInvalidSignature = errors.New("invalid signature")
ErrCompressedTagMismatch = errors.New("Compressed tag mismatch")
ErrDatapathVersionMismatch = errors.New("Datapath version mismatch")
ErrTokenDecodeFailed = errors.New("unable to decode token")
ErrTokenExpired = errors.New("token expired")
ErrSignatureMismatch = errors.New("signature mismatch")
ErrSharedKeyHashFailed = errors.New("unable to hash shared key")
ErrPublicKeyFailed = errors.New("unable to verify public key")
)
// logError is a convinience function which logs the err:msg and returns the error.
func logError(err error, msg string) error {
if err == nil {
return nil
}
return fmt.Errorf("err = err.Error(), msg = %s", msg)
}