fix nil err
This commit is contained in:
parent
e9716a72e6
commit
def7dda8d9
@ -31,6 +31,9 @@ func (ex *custom) With(innerErr ...error) Custom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ex *custom) IsSameAs(err error) bool {
|
func (ex *custom) IsSameAs(err error) bool {
|
||||||
|
if err == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return strings.HasPrefix(err.Error(), fmt.Sprintf("[%s]:", ex.message))
|
return strings.HasPrefix(err.Error(), fmt.Sprintf("[%s]:", ex.message))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -46,6 +46,7 @@ func (suite *CustomExceptionTestSuite) TestShouldCompareExceptions() {
|
|||||||
suite.False(NotFoundException.IsSameAs(InvalidArgumentException))
|
suite.False(NotFoundException.IsSameAs(InvalidArgumentException))
|
||||||
suite.False(NotFoundException.IsSameAs(customErr))
|
suite.False(NotFoundException.IsSameAs(customErr))
|
||||||
suite.False(InvalidArgumentException.IsSameAs(customErr))
|
suite.False(InvalidArgumentException.IsSameAs(customErr))
|
||||||
|
suite.False(InvalidArgumentException.IsSameAs(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCustomExceptionTestSuite(t *testing.T) {
|
func TestCustomExceptionTestSuite(t *testing.T) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user