From cae23f036ac639141153a73551bcabbb7169e9e0 Mon Sep 17 00:00:00 2001 From: Scott Lawrence Date: Mon, 31 Oct 2011 16:07:17 -0700 Subject: [PATCH] template: fix error checking on execute without parse Fixed error checking in exec.go to give a sensible error message when execution is attempted before a successful parse (rather than an outright panic). R=r CC=golang-dev https://golang.org/cl/5306065 --- src/pkg/exp/template/html/escape_test.go | 12 ++++++------ src/pkg/template/exec.go | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pkg/exp/template/html/escape_test.go b/src/pkg/exp/template/html/escape_test.go index a4ea7596cd1..1b3b2567335 100644 --- a/src/pkg/exp/template/html/escape_test.go +++ b/src/pkg/exp/template/html/escape_test.go @@ -1549,8 +1549,8 @@ func TestEnsurePipelineContains(t *testing.T) { } } -func expectExecuteFailure(t *testing.T, b *bytes.Buffer) { - if x := recover(); x != nil { +func expectExecuteFailure(t *testing.T, b *bytes.Buffer, err os.Error) { + if err != nil { if b.Len() != 0 { t.Errorf("output on buffer: %q", b.String()) } @@ -1563,8 +1563,8 @@ func TestEscapeErrorsNotIgnorable(t *testing.T) { var b bytes.Buffer tmpl := template.Must(template.New("dangerous").Parse("