mirror of
https://github.com/golang/go
synced 2024-11-24 21:10:04 -07:00
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
This commit is contained in:
parent
793768e9d5
commit
f5d024a746
@ -78,10 +78,14 @@ func (s *state) error(err error) {
|
||||
func errRecover(errp *error) {
|
||||
e := recover()
|
||||
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)
|
||||
}
|
||||
*errp = e.(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user