summaryrefslogtreecommitdiff
path: root/errors.go
blob: 8760316f4e7cb68cd343898f2164509fc12c12d1 (plain) (blame)
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
66
67
package securecookie

import "errors"

func NewUsageError(err error) *cookieError {
	return &cookieError{cause: err, typ: usageError}
}

func NewInternalError(err error) *cookieError {
	return &cookieError{cause: err, typ: internalError}
}

func NewDecodeError(err error) *cookieError {
	return &cookieError{cause: err, typ: decodeError}
}

func IsValueTooLong(err error) bool {
	return errors.Is(err, errEncodedValueTooLong) || errors.Is(err, errValueToDecodeTooLong)
}

func IsEncodedValueTooLong(err error) bool {
	return errors.Is(err, errEncodedValueTooLong)
}

func IsDecodeValueTooLong(err error) bool {
	return errors.Is(err, errValueToDecodeTooLong)
}

func IsNoCodecs(err error) bool {
	return errors.Is(err, errNoCodecs)
}

func IsHashKeyNotSet(err error) bool {
	return errors.Is(err, errHashKeyNotSet)
}

func IsBlockKeyNotSet(err error) bool {
	return errors.Is(err, errBlockKeyNotSet)
}

func IsTimestampInvalid(err error) bool {
	return errors.Is(err, errTimestampInvalid)
}

func IsTimestampTooNew(err error) bool {
	return errors.Is(err, errTimestampTooNew)
}

func IsTimestampExpired(err error) bool {
	return errors.Is(err, errTimestampExpired)
}

func IsDecryptionFailed(err error) bool {
	return errors.Is(err, errDecryptionFailed)
}

func IsValueNotByte(err error) bool {
	return errors.Is(err, errValueNotByte)
}

func IsValueNotBytePtr(err error) bool {
	return errors.Is(err, errValueNotBytePtr)
}

func IsMacInvalid(err error) bool {
	return errors.Is(err, ErrMacInvalid)
}