]> Cypherpunks repositories - gostls13.git/commitdiff
html/template, text/template: drop defined template list from errors
authorRuss Cox <rsc@golang.org>
Wed, 26 Oct 2016 17:12:17 +0000 (13:12 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 28 Oct 2016 17:10:55 +0000 (17:10 +0000)
The report in #17414 points out that if you have many many templates,
then this is an overwhelming list and just hurts the signal-to-noise ratio of the error.

Even the test of the old behavior also supports the idea that this is noise:

template: empty: "empty" is an incomplete or empty template; defined templates are: "secondary"

The chance that someone mistyped "secondary" as "empty" is slim at best.

Similarly, the compiler does not augment an error like 'unknown variable x'
by dumping the full list of all the known variables.

For all these reasons, drop the list.

Fixes #17414.

Change-Id: I78f92d2c591df7218385fe723a4abc497913acf8
Reviewed-on: https://go-review.googlesource.com/32116
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/html/template/template.go
src/text/template/exec.go
src/text/template/exec_test.go

index 9eaab4be6aa3dce0bc7ccaaf2d48427018ab184b..a98d151c507e6e912225ce7e1d6ae1688fa51093 100644 (file)
@@ -96,7 +96,7 @@ func (t *Template) escape() error {
        t.nameSpace.escaped = true
        if t.escapeErr == nil {
                if t.Tree == nil {
-                       return fmt.Errorf("template: %q is an incomplete or empty template%s", t.Name(), t.DefinedTemplates())
+                       return fmt.Errorf("template: %q is an incomplete or empty template", t.Name())
                }
                if err := escapeTemplate(t, t.text.Root, t.Name()); err != nil {
                        return err
index 5a6e454ec611f9d4cea8db992521ef700a1cc44e..7db4a87d2ea82673c7da9227047c1063a79617f4 100644 (file)
@@ -190,7 +190,7 @@ func (t *Template) execute(wr io.Writer, data interface{}) (err error) {
                vars: []variable{{"$", value}},
        }
        if t.Tree == nil || t.Root == nil {
-               state.errorf("%q is an incomplete or empty template%s", t.Name(), t.DefinedTemplates())
+               state.errorf("%q is an incomplete or empty template", t.Name())
        }
        state.walk(value, t.Root)
        return
index 1c7e115554570a8e211a91b5629bb0282768182e..99b9434b783606f1c8a928d80b12b296f5260f13 100644 (file)
@@ -932,7 +932,7 @@ func TestMessageForExecuteEmpty(t *testing.T) {
                t.Fatal("expected second error")
        }
        got = err.Error()
-       want = `template: empty: "empty" is an incomplete or empty template; defined templates are: "secondary"`
+       want = `template: empty: "empty" is an incomplete or empty template`
        if got != want {
                t.Errorf("expected error %s got %s", want, got)
        }