From bee148bf23701f1b82d4d1d1187e3ef60ba724d7 Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Tue, 22 Jan 2013 02:48:40 +0800 Subject: [PATCH] text/template/parse: don't show itemType in error messages so that the user don't need to decipher something like this: template: main:1: expected %!s(parse.itemType=14) in end; got "|" now they get this: template: main:1: unexpected "|" in end R=golang-dev, r CC=golang-dev https://golang.org/cl/7128054 --- src/pkg/text/template/parse/parse.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pkg/text/template/parse/parse.go b/src/pkg/text/template/parse/parse.go index 250cad5f35..c0fb9274a3 100644 --- a/src/pkg/text/template/parse/parse.go +++ b/src/pkg/text/template/parse/parse.go @@ -151,7 +151,7 @@ func (t *Tree) error(err error) { func (t *Tree) expect(expected itemType, context string) item { token := t.nextNonSpace() if token.typ != expected { - t.errorf("expected %s in %s; got %s", expected, context, token) + t.unexpected(token, context) } return token } @@ -160,7 +160,7 @@ func (t *Tree) expect(expected itemType, context string) item { func (t *Tree) expectOneOf(expected1, expected2 itemType, context string) item { token := t.nextNonSpace() if token.typ != expected1 && token.typ != expected2 { - t.errorf("expected %s or %s in %s; got %s", expected1, expected2, context, token) + t.unexpected(token, context) } return token } -- 2.48.1