From: Shenghou Ma Date: Mon, 21 Jan 2013 18:48:40 +0000 (+0800) Subject: text/template/parse: don't show itemType in error messages X-Git-Tag: go1.1rc2~1333 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=bee148bf23701f1b82d4d1d1187e3ef60ba724d7;p=gostls13.git 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 --- 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 }