refactor: replace if MatchString with FindStringSubMatch

Signed-off-by: Jesse Simpson <jesse.simpson36@gmail.com>
pull/13586/head
Jesse Simpson 6 months ago
parent 782f6c6409
commit 65084371c9
No known key found for this signature in database
GPG Key ID: 237495C89AB0AAFC

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

Loading…
Cancel
Save