From 2cef1462990218659e9f69411a068f8f377914cf Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Tue, 6 Aug 2024 13:04:09 +0200 Subject: [PATCH] lintcmd: panic with the right message when we can't parse a position (cherry picked from commit 4a7ea0e540d6d861d1e0971b0f583496ff35b31c) --- lintcmd/lint.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lintcmd/lint.go b/lintcmd/lint.go index 0b588a97..0a58e514 100644 --- a/lintcmd/lint.go +++ b/lintcmd/lint.go @@ -456,7 +456,7 @@ func failed(res runner.Result) []diagnostic { var err error posn, _, err = parsePos(e.Pos) if err != nil { - panic(fmt.Sprintf("internal error: %s", e)) + panic(fmt.Sprintf("internal error: %s", err)) } } diag := diagnostic{ @@ -558,7 +558,7 @@ func parsePos(pos string) (token.Position, int, error) { } parts := posRe.FindStringSubmatch(pos) if parts == nil { - return token.Position{}, 0, fmt.Errorf("internal error: malformed position %q", pos) + return token.Position{}, 0, fmt.Errorf("malformed position %q", pos) } file := parts[1] line, _ := strconv.Atoi(parts[2])