refactor: shorten regex subexp syntax

Signed-off-by: Jesse Simpson <jesse.simpson36@gmail.com>
This commit is contained in:
Jesse Simpson
2025-03-17 12:37:18 -04:00
parent 4b9a9ecaf6
commit 782f6c6409

View File

@@ -384,14 +384,10 @@ func reformatExecErrorMsg(filename string, err error) error {
var traceable TraceableError
if execErrFmt.MatchString(current.Error()) {
matches := execErrFmt.FindStringSubmatch(current.Error())
templateIndex := execErrFmt.SubexpIndex("templateName")
templateName := matches[templateIndex]
functionNameIndex := execErrFmt.SubexpIndex("functionName")
functionName := matches[functionNameIndex]
locationNameIndex := execErrFmt.SubexpIndex("location")
locationName := matches[locationNameIndex]
errMsgIndex := execErrFmt.SubexpIndex("errMsg")
errMsg := matches[errMsgIndex]
templateName := matches[execErrFmt.SubexpIndex("templateName")]
functionName := matches[execErrFmt.SubexpIndex("functionName")]
locationName := matches[execErrFmt.SubexpIndex("location")]
errMsg := matches[execErrFmt.SubexpIndex("errMsg")]
traceable = TraceableError{
location: templateName,
message: errMsg,
@@ -399,10 +395,8 @@ func reformatExecErrorMsg(filename string, err error) error {
}
} else if execErrFmtWithoutTemplate.MatchString(current.Error()) {
matches := execErrFmt.FindStringSubmatch(current.Error())
templateIndex := execErrFmt.SubexpIndex("templateName")
templateName := matches[templateIndex]
errMsgIndex := execErrFmt.SubexpIndex("errMsg")
errMsg := matches[errMsgIndex]
templateName := matches[execErrFmt.SubexpIndex("templateName")]
errMsg := matches[execErrFmt.SubexpIndex("errMsg")]
traceable = TraceableError{
location: templateName,
message: errMsg,