Skip to content

Commit

Permalink
add panic recovery to help debug
Browse files Browse the repository at this point in the history
  • Loading branch information
dshiell committed Sep 7, 2024
1 parent a73de1f commit 5b0ade7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions common/json_rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"sort"
"strings"

Expand Down Expand Up @@ -50,6 +51,13 @@ func (r *JsonRpcResponse) ParsedResult() (interface{}, error) {
return nil, nil
}

defer func() {
if rec := recover(); rec != nil {
// Catch the panic and log the raw JSON
log.Printf("Panic occurred: %v\n", rec)
log.Printf("Raw JSON response: %s\n", r.Result)
}
}()
err := sonic.Unmarshal(r.Result, &r.parsedResult)
if err != nil {
return nil, err
Expand Down

0 comments on commit 5b0ade7

Please sign in to comment.