From 1cb0c5289093305a0f28b3371fd38e792d9617e1 Mon Sep 17 00:00:00 2001 From: Hank Shen Date: Mon, 9 Oct 2023 13:20:51 +0800 Subject: update --- errors.go | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 errors.go diff --git a/errors.go b/errors.go new file mode 100644 index 0000000..9d9833d --- /dev/null +++ b/errors.go @@ -0,0 +1,55 @@ +package securecookie + +import "errors" + +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) +} -- cgit v1.2.3