Commit f5d024a7 authored by Rémy Oudompheng's avatar Rémy Oudompheng Committed by Rob Pike

text/template: handle panic values that are not errors.

The recover code assumes that the panic() argument was
an error, but it is usually a simple string.
Fixes #2663.

R=golang-dev, r, r, gri
CC=golang-dev, remy
https://golang.org/cl/5527046
parent 793768e9
...@@ -78,10 +78,14 @@ func (s *state) error(err error) { ...@@ -78,10 +78,14 @@ func (s *state) error(err error) {
func errRecover(errp *error) { func errRecover(errp *error) {
e := recover() e := recover()
if e != nil { if e != nil {
if _, ok := e.(runtime.Error); ok { switch err := e.(type) {
case runtime.Error:
panic(e)
case error:
*errp = err
default:
panic(e) panic(e)
} }
*errp = e.(error)
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment