diff --git a/errors/const.go b/errors/const.go index 4e9573f..26f71c6 100644 --- a/errors/const.go +++ b/errors/const.go @@ -19,4 +19,10 @@ const ( // if the argument is not valid InvalidArgument ErrCode = 3 + + // Unauthorized request error + Unauthorized ErrCode = 4 + + // Forbidden action error + Forbidden ErrCode = 5 ) diff --git a/errors/errors.go b/errors/errors.go index 9d2e677..6555be9 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -74,3 +74,15 @@ func IsAlreadyExists(err error) bool { func IsInvalidArgument(err error) bool { return GetErrCode(err) == InvalidArgument } + +// IsUnauthorized returns true if err +// is due to Unauthorized request +func IsUnauthorized(err error) bool { + return GetErrCode(err) == Unauthorized +} + +// IsForbidden returns true if err +// is due to Forbidden action +func IsForbidden(err error) bool { + return GetErrCode(err) == Forbidden +}