From c4c69e1c7f1cb61bc6f4d0c997f149d0da1a85b9 Mon Sep 17 00:00:00 2001 From: Craig Peterson Date: Tue, 4 Aug 2015 10:10:41 -0600 Subject: [PATCH] cmd/bosun: recovering from panic in chart rendering. Just in case. --- cmd/bosun/sched/template.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/bosun/sched/template.go b/cmd/bosun/sched/template.go index d159aa19d1..65697b5ed6 100644 --- a/cmd/bosun/sched/template.go +++ b/cmd/bosun/sched/template.go @@ -20,6 +20,7 @@ import ( "bosun.org/cmd/bosun/expr" "bosun.org/cmd/bosun/expr/parse" "bosun.org/opentsdb" + "bosun.org/slog" ) type Context struct { @@ -290,7 +291,13 @@ func (c *Context) EvalAll(v interface{}) (interface{}, error) { return res, err } -func (c *Context) graph(v interface{}, unit string, filter bool) (interface{}, error) { +func (c *Context) graph(v interface{}, unit string, filter bool) (val interface{}, err error) { + defer func() { + if p := recover(); p != nil { + slog.Error("panic rendering graph", p) + val = "error rendering graph" + } + }() res, exprText, err := c.eval(v, filter, true, 1000) if err != nil { return nil, err