From a0f0b823485b1475d26d617f94791a2a94e6f5cc Mon Sep 17 00:00:00 2001 From: Brian Brazil Date: Sun, 2 Aug 2015 23:26:21 +0100 Subject: [PATCH] promql: Test errors aren't always ParseErr --- promql/test.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/promql/test.go b/promql/test.go index 3e5e4fcc2..d7c45b57f 100644 --- a/promql/test.go +++ b/promql/test.go @@ -114,8 +114,9 @@ func (t *Test) parseLoad(lines []string, i int) (int, *loadCmd, error) { } metric, vals, err := parseSeriesDesc(defLine) if err != nil { - perr := err.(*ParseErr) - perr.Line = i + 1 + if perr, ok := err.(*ParseErr); ok { + perr.Line = i + 1 + } return i, nil, err } cmd.set(metric, vals...) @@ -135,10 +136,11 @@ func (t *Test) parseEval(lines []string, i int) (int, *evalCmd, error) { ) expr, err := ParseExpr(qry) if err != nil { - perr := err.(*ParseErr) - perr.Line = i + 1 - perr.Pos += strings.Index(lines[i], qry) - return i, nil, perr + if perr, ok := err.(*ParseErr); ok { + perr.Line = i + 1 + perr.Pos += strings.Index(lines[i], qry) + } + return i, nil, err } offset, err := strutil.StringToDuration(at) @@ -168,8 +170,9 @@ func (t *Test) parseEval(lines []string, i int) (int, *evalCmd, error) { } metric, vals, err := parseSeriesDesc(defLine) if err != nil { - perr := err.(*ParseErr) - perr.Line = i + 1 + if perr, ok := err.(*ParseErr); ok { + perr.Line = i + 1 + } return i, nil, err }