From b71525ba30e2a48b2349d9ce9c846226ea739df6 Mon Sep 17 00:00:00 2001 From: Samuel Lorch Date: Fri, 7 Apr 2023 21:54:29 +0200 Subject: [PATCH] Respond with error in case of panic --- internal/jsonrpc/handler.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/jsonrpc/handler.go b/internal/jsonrpc/handler.go index 0e8d7ce..278d3cc 100644 --- a/internal/jsonrpc/handler.go +++ b/internal/jsonrpc/handler.go @@ -82,6 +82,7 @@ func (h *Handler) HandleRequest(ctx context.Context, s *session.Session, r io.Re defer func() { if r := recover(); r != nil { slog.Error("Recovered Panic Executing API Method", fmt.Errorf("%v", r), "method", req.Method, "params", fmt.Sprintf("%+v", params[2]), "id", req.ID, "stack", debug.Stack()) + respondError(w, req.ID, ErrInternalError, fmt.Errorf("%v", r)) } }() res := method.handlerFunc.Call(params)