From ad71cacb821aaabf1f5bf0098790b6b13bf9bf2a Mon Sep 17 00:00:00 2001 From: Michael Kaye <1917473+michaelkaye@users.noreply.github.com> Date: Thu, 22 Nov 2018 18:47:31 +0000 Subject: [PATCH] Log failed template parsing reasons to console. When using the API, you can fail to parse but be unaware of why. Provide that context on the console. --- .../go-neb/services/alertmanager/alertmanager.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/github.com/matrix-org/go-neb/services/alertmanager/alertmanager.go b/src/github.com/matrix-org/go-neb/services/alertmanager/alertmanager.go index dde808f..d492fc0 100644 --- a/src/github.com/matrix-org/go-neb/services/alertmanager/alertmanager.go +++ b/src/github.com/matrix-org/go-neb/services/alertmanager/alertmanager.go @@ -129,6 +129,10 @@ func (s *Service) Register(oldService types.Service, client *gomatrix.Client) er // validate the plain text template is valid _, err := text.New("textTemplate").Parse(templates.TextTemplate) if err != nil { + log.WithFields(log.Fields{ + "line": err.line, + "description": err.description, + }).Info("plain text Template Error") return fmt.Errorf("plain text template is invalid") } } @@ -136,6 +140,10 @@ func (s *Service) Register(oldService types.Service, client *gomatrix.Client) er // validate that the html template is valid _, err := html.New("htmlTemplate").Parse(templates.HTMLTemplate) if err != nil { + log.WithFields(log.Fields{ + "line": err.line, + "description": err.description, + }).Info("HTML Template Error") return fmt.Errorf("html template is invalid") } }