refactor: shorten regex subexp syntax

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

@ -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,

Loading…
Cancel
Save