Skip to content

Commit 35888fa

Browse files
author
Gaylor Bosson
committed
Fix panic in encode recovering
This fixes the panic that was happening when the recover had an error type different than a string.
1 parent 3da338c commit 35888fa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

encode.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type encoder struct {
4141
func Encode(structPtr interface{}) (bytes []byte, err error) {
4242
defer func() {
4343
if e := recover(); e != nil {
44-
err = errors.New(e.(string))
44+
err = fmt.Errorf("%v", e)
4545
bytes = nil
4646
}
4747
}()

0 commit comments

Comments
 (0)