Skip to content

Commit

Permalink
fix: better error stack message for template function
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Feb 7, 2022
1 parent 1585395 commit 2c7ac29
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions 4_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func getRegexFuncs(regexCache map[string]*regexp.Regexp) template.FuncMap {
if !exists {
r, err := regexp.Compile(regex)
if err != nil {
return false, err
return false, errors.WithStack(err)
}
regexCache[regex] = r
}
Expand All @@ -58,7 +58,7 @@ func getRegexFuncs(regexCache map[string]*regexp.Regexp) template.FuncMap {
if !exists {
r, err := regexp.Compile(regex)
if err != nil {
return []string{}, err
return []string{}, errors.WithStack(err)
}
regexCache[regex] = r
}
Expand All @@ -79,7 +79,7 @@ func getRegexFuncs(regexCache map[string]*regexp.Regexp) template.FuncMap {
if !exists {
r, err := regexp.Compile(regex)
if err != nil {
return "", err
return "", errors.WithStack(err)
}
regexCache[regex] = r
}
Expand All @@ -100,7 +100,7 @@ func getRegexFuncs(regexCache map[string]*regexp.Regexp) template.FuncMap {
if !exists {
r, err := regexp.Compile(regex)
if err != nil {
return "", err
return "", errors.WithStack(err)
}
regexCache[regex] = r
}
Expand All @@ -121,7 +121,7 @@ func getRegexFuncs(regexCache map[string]*regexp.Regexp) template.FuncMap {
if !exists {
r, err := regexp.Compile(regex)
if err != nil {
return "", err
return "", errors.WithStack(err)
}
regexCache[regex] = r
}
Expand All @@ -142,7 +142,7 @@ func getRegexFuncs(regexCache map[string]*regexp.Regexp) template.FuncMap {
if !exists {
r, err := regexp.Compile(regex)
if err != nil {
return []string{}, err
return []string{}, errors.WithStack(err)
}
regexCache[regex] = r
}
Expand Down Expand Up @@ -185,7 +185,7 @@ func GenerateFromContext(g *client.GitClient, contexts []*TemplateContext, forma
}
} else {
if b, err := ioutil.ReadFile(templateFile); err != nil {
return nil, err
return nil, errors.WithStack(err)
} else {
templateStr = string(b)
}
Expand Down

0 comments on commit 2c7ac29

Please sign in to comment.