style: create String function for TraceableError representing one chunk of a stacktrace

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

@ -336,6 +336,10 @@ type TraceableError struct {
executedFunction string executedFunction string
} }
func (t TraceableError) String() string {
return t.location + "\n " + t.executedFunction + "\n " + t.message + "\n"
}
func cleanupExecError(filename string, err error) error { func cleanupExecError(filename string, err error) error {
if _, isExecError := err.(template.ExecError); !isExecError { if _, isExecError := err.(template.ExecError); !isExecError {
return err return err
@ -419,7 +423,7 @@ func cleanupExecError(filename string, err error) error {
if i.message == "" { if i.message == "" {
continue continue
} }
finalErrorString = finalErrorString + "\n" + i.location + "\n " + i.executedFunction + "\n " + i.message finalErrorString = finalErrorString + i.String()
} }
return fmt.Errorf("NEW ERROR FORMAT: \n%s\n\n\nORIGINAL ERROR:\n%s", finalErrorString, err.Error()) return fmt.Errorf("NEW ERROR FORMAT: \n%s\n\n\nORIGINAL ERROR:\n%s", finalErrorString, err.Error())

Loading…
Cancel
Save