Skip to content

Commit 894dbac

Browse files
commonerrors Add ErrFailed
1 parent b3aeef0 commit 894dbac

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

changes/20250807151301.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:sparkles: `commonerrors` Add ErrFailed

utils/commonerrors/errors.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ var (
4545
ErrEOF = errors.New("end of file")
4646
ErrMalicious = errors.New("suspected malicious intent")
4747
ErrOutOfRange = errors.New("out of range")
48+
ErrFailed = errors.New("failed")
4849
// ErrWarning is a generic error that can be used when an error should be raised but it shouldn't necessary be
4950
// passed up the chain, for example in cases where an error should be logged but the program should continue. In
5051
// these situations it should be handled immediately and then ignored/set to nil.
@@ -57,7 +58,7 @@ var warningStrPrepend = fmt.Sprintf("%v: ", warningStr)
5758

5859
// IsCommonError returns whether an error is a commonerror
5960
func IsCommonError(target error) bool {
60-
return Any(target, ErrNotImplemented, ErrNoExtension, ErrNoLogger, ErrNoLoggerSource, ErrNoLogSource, ErrUndefined, ErrInvalidDestination, ErrTimeout, ErrLocked, ErrStaleLock, ErrExists, ErrNotFound, ErrUnsupported, ErrUnavailable, ErrWrongUser, ErrUnauthorised, ErrUnknown, ErrInvalid, ErrConflict, ErrMarshalling, ErrCancelled, ErrEmpty, ErrUnexpected, ErrTooLarge, ErrForbidden, ErrCondition, ErrEOF, ErrMalicious, ErrWarning, ErrOutOfRange)
61+
return Any(target, ErrNotImplemented, ErrNoExtension, ErrNoLogger, ErrNoLoggerSource, ErrNoLogSource, ErrUndefined, ErrInvalidDestination, ErrTimeout, ErrLocked, ErrStaleLock, ErrExists, ErrNotFound, ErrUnsupported, ErrUnavailable, ErrWrongUser, ErrUnauthorised, ErrUnknown, ErrInvalid, ErrConflict, ErrMarshalling, ErrCancelled, ErrEmpty, ErrUnexpected, ErrTooLarge, ErrForbidden, ErrCondition, ErrEOF, ErrMalicious, ErrWarning, ErrOutOfRange, ErrFailed)
6162
}
6263

6364
// Any determines whether the target error is of the same type as any of the errors `err`
@@ -183,6 +184,8 @@ func deserialiseCommonError(errStr string) (bool, error) {
183184
return true, ErrWarning
184185
case CorrespondTo(ErrOutOfRange, errStr):
185186
return true, ErrOutOfRange
187+
case CorrespondTo(ErrFailed, errStr):
188+
return true, ErrFailed
186189
}
187190
return false, ErrUnknown
188191
}

utils/commonerrors/errors_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ func TestIsCommonError(t *testing.T) {
112112
ErrMalicious,
113113
ErrWarning,
114114
ErrOutOfRange,
115+
ErrFailed,
115116
}
116117
for i := range commonErrors {
117118
assert.True(t, IsCommonError(commonErrors[i]))

0 commit comments

Comments
 (0)