fix nil err

This commit is contained in:
admin 2025-08-07 15:56:29 +02:00
parent e9716a72e6
commit def7dda8d9
2 changed files with 4 additions and 0 deletions

View File

@ -31,6 +31,9 @@ func (ex *custom) With(innerErr ...error) Custom {
}
func (ex *custom) IsSameAs(err error) bool {
if err == nil {
return false
}
return strings.HasPrefix(err.Error(), fmt.Sprintf("[%s]:", ex.message))
}

View File

@ -46,6 +46,7 @@ func (suite *CustomExceptionTestSuite) TestShouldCompareExceptions() {
suite.False(NotFoundException.IsSameAs(InvalidArgumentException))
suite.False(NotFoundException.IsSameAs(customErr))
suite.False(InvalidArgumentException.IsSameAs(customErr))
suite.False(InvalidArgumentException.IsSameAs(nil))
}
func TestCustomExceptionTestSuite(t *testing.T) {