return error when regex generation fails

This commit is contained in:
Carlosokumu 2024-10-12 13:30:46 +03:00
parent 0837933b6c
commit d9e922d5be
Signed by untrusted user: carlos
GPG Key ID: 7BD6BC8160A5C953

View File

@ -14,7 +14,10 @@ type Step struct {
func (s *Step) MatchesExpectedContent(content []byte) (bool, error) { func (s *Step) MatchesExpectedContent(content []byte) (bool, error) {
pattern := regexp.QuoteMeta(s.ExpectedContent) pattern := regexp.QuoteMeta(s.ExpectedContent)
re, _ := regexp.Compile(pattern) re, err := regexp.Compile(pattern)
if err != nil {
return false, err
}
if re.Match([]byte(content)) { if re.Match([]byte(content)) {
return true, nil return true, nil
} }