We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0af9cf4 commit fac361cCopy full SHA for fac361c
testing/v2/checker__error.go
@@ -10,7 +10,7 @@ import (
10
func ErrorMatch(re *regexp.Regexp) ValueChecker[error] {
11
return internal.Helper(1, &beChecker[error]{
12
be: func(actual error) error {
13
- if re.MatchString(actual.Error()) {
+ if actual != nil && re.MatchString(actual.Error()) {
14
return nil
15
}
16
return &ErrNotEqual{
@@ -24,7 +24,7 @@ func ErrorMatch(re *regexp.Regexp) ValueChecker[error] {
24
func ErrorNotMatch(re *regexp.Regexp) ValueChecker[error] {
25
26
27
- if !re.MatchString(actual.Error()) {
+ if actual == nil || !re.MatchString(actual.Error()) {
28
29
30
return &ErrEqual{
0 commit comments