From 2c7ac29d1d7feda1f3c1d7831701c5a43b1f0339 Mon Sep 17 00:00:00 2001 From: Axetroy Date: Mon, 7 Feb 2022 17:55:42 +0800 Subject: [PATCH] fix: better error stack message for template function --- 4_generator.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/4_generator.go b/4_generator.go index 205ec9b2..4a2faea0 100644 --- a/4_generator.go +++ b/4_generator.go @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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) }