added rpc error data
This commit is contained in:
parent
b2cde35375
commit
5ea95f245f
|
@ -131,7 +131,7 @@ func getResponse[T any](
|
|||
return fmt.Errorf("failed to decode %s response body: %w", method, err)
|
||||
}
|
||||
|
||||
// last error check:
|
||||
// check for an actual rpc error
|
||||
if rpcResponse.Error.Code != 0 {
|
||||
return &rpcResponse.Error
|
||||
}
|
||||
|
|
|
@ -7,8 +7,9 @@ import (
|
|||
|
||||
type (
|
||||
RPCError struct {
|
||||
Message string `json:"message"`
|
||||
Code int64 `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Code int64 `json:"code"`
|
||||
Data map[string]any `json:"data"`
|
||||
}
|
||||
|
||||
response[T any] struct {
|
||||
|
@ -97,7 +98,7 @@ type (
|
|||
)
|
||||
|
||||
func (e *RPCError) Error() string {
|
||||
return fmt.Sprintf("RPC Error (%d): %s", e.Code, e.Message)
|
||||
return fmt.Sprintf("rpc error (code: %d): %s (data: %v)", e.Code, e.Message, e.Data)
|
||||
}
|
||||
|
||||
func (hp *HostProduction) UnmarshalJSON(data []byte) error {
|
||||
|
|
Loading…
Reference in New Issue