Add UnsupportedFlag to the declared errors

Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
This commit is contained in:
Ulysses Souza 2021-09-16 16:36:30 +02:00
parent 21d3b19e57
commit 1150a323ab
1 changed files with 7 additions and 0 deletions

View File

@ -42,6 +42,8 @@ var (
// ErrNotImplemented is returned when a backend doesn't implement // ErrNotImplemented is returned when a backend doesn't implement
// an action // an action
ErrNotImplemented = errors.New("not implemented") ErrNotImplemented = errors.New("not implemented")
// ErrUnsupportedFlag is returned when a backend doesn't support a flag
ErrUnsupportedFlag = errors.New("unsupported flag")
// ErrCanceled is returned when the command was canceled by user // ErrCanceled is returned when the command was canceled by user
ErrCanceled = errors.New("canceled") ErrCanceled = errors.New("canceled")
// ErrParsingFailed is returned when a string cannot be parsed // ErrParsingFailed is returned when a string cannot be parsed
@ -71,6 +73,11 @@ func IsUnknownError(err error) bool {
return errors.Is(err, ErrUnknown) return errors.Is(err, ErrUnknown)
} }
// IsErrUnsupportedFlag returns true if the unwrapped error is ErrUnsupportedFlag
func IsErrUnsupportedFlag(err error) bool {
return errors.Is(err, ErrUnsupportedFlag)
}
// IsErrNotImplemented returns true if the unwrapped error is ErrNotImplemented // IsErrNotImplemented returns true if the unwrapped error is ErrNotImplemented
func IsErrNotImplemented(err error) bool { func IsErrNotImplemented(err error) bool {
return errors.Is(err, ErrNotImplemented) return errors.Is(err, ErrNotImplemented)