-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Milestone
Description
The current logic in json/decode.go
does the following:
go/src/encoding/json/decode.go
Lines 173 to 178 in 7eb7f8f
if r := recover(); r != nil { | |
if _, ok := r.(runtime.Error); ok { | |
panic(r) | |
} | |
err = r.(error) | |
} |
This captures any panics that aren't runtime.Error
, which is arguably a wider range of panics than should be captured. For example, a panic in the reflect package gets masked away as an error.
The logic in decodeState.error
should wrap the error before panicking to ensure the recover only captures errors originating from the json
package:
go/src/encoding/json/decode.go
Lines 298 to 301 in 7eb7f8f
// error aborts the decoding by panicking with err. | |
func (d *decodeState) error(err error) { | |
panic(d.addErrorContext(err)) | |
} |