From 2491cdc2cc3ace2b11ef18436f0b315486044cad Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Wed, 1 Jun 2022 17:38:58 -0500 Subject: [PATCH] :bug: Log first error instead of last during failures --- internal/visitor/template_comments.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/visitor/template_comments.go b/internal/visitor/template_comments.go index abd8f72..45c55d9 100644 --- a/internal/visitor/template_comments.go +++ b/internal/visitor/template_comments.go @@ -28,13 +28,17 @@ func (v *TemplateComments) Visit(n ast.Node) ast.Visitor { if comment := node.GetCommentTmpl(v.conf.Prefix, n.Value); comment != "" { newNode, err := templateComment(v.conf, comment, n.Value) if err != nil { - v.err = err + if v.err == nil { + v.err = err + } return nil } if newNode != nil { if err := n.Replace(newNode); err != nil { - v.err = err + if v.err == nil { + v.err = err + } return nil } } @@ -44,13 +48,17 @@ func (v *TemplateComments) Visit(n ast.Node) ast.Visitor { if comment := node.GetCommentTmpl(v.conf.Prefix, value); comment != "" { newNode, err := templateComment(v.conf, comment, value) if err != nil { - v.err = err + if v.err == nil { + v.err = err + } return nil } if newNode != nil { if err := n.Replace(i, newNode); err != nil { - v.err = err + if v.err == nil { + v.err = err + } return nil } }