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

Loading…
Cancel
Save