update script error handling

This commit is contained in:
2025-08-01 23:53:30 +03:00
parent 9a274250cd
commit 520901c331
4 changed files with 34 additions and 14 deletions

View File

@@ -2,7 +2,18 @@ package rpc
import "encoding/json"
func NewError(code int, message string, id *json.RawMessage) *RPCResponse {
func NewError(code int, message string, data any, id *json.RawMessage) *RPCResponse {
if data != nil {
return &RPCResponse{
JSONRPC: JSONRPCVersion,
ID: id,
Error: map[string]any{
"code": code,
"message": message,
"data": data,
},
}
}
return &RPCResponse{
JSONRPC: JSONRPCVersion,
ID: id,