refactor: replace if MatchString with FindStringSubMatch

Signed-off-by: Jesse Simpson <jesse.simpson36@gmail.com>
This commit is contained in:
Jesse Simpson 2025-03-17 12:39:55 -04:00
parent 782f6c6409
commit 65084371c9
No known key found for this signature in database
GPG key ID: 237495C89AB0AAFC

View file

@ -382,8 +382,7 @@ func reformatExecErrorMsg(filename string, err error) error {
}
var traceable TraceableError
if execErrFmt.MatchString(current.Error()) {
matches := execErrFmt.FindStringSubmatch(current.Error())
if matches := execErrFmt.FindStringSubmatch(current.Error()); matches != nil {
templateName := matches[execErrFmt.SubexpIndex("templateName")]
functionName := matches[execErrFmt.SubexpIndex("functionName")]
locationName := matches[execErrFmt.SubexpIndex("location")]
@ -393,8 +392,7 @@ func reformatExecErrorMsg(filename string, err error) error {
message: errMsg,
executedFunction: "executing " + functionName + " at " + locationName + ":",
}
} else if execErrFmtWithoutTemplate.MatchString(current.Error()) {
matches := execErrFmt.FindStringSubmatch(current.Error())
} else if matches := execErrFmtWithoutTemplate.FindStringSubmatch(current.Error()); matches != nil {
templateName := matches[execErrFmt.SubexpIndex("templateName")]
errMsg := matches[execErrFmt.SubexpIndex("errMsg")]
traceable = TraceableError{