Skip to content

Commit

Permalink
Merge pull request asymmetric-research#44 from asymmetric-research/er…
Browse files Browse the repository at this point in the history
…ror-update

Added rpc error data
  • Loading branch information
johnstonematt authored Oct 17, 2024
2 parents e3c8396 + 5ea95f2 commit 7be0a71
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,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
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/rpc/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -98,7 +99,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 {
Expand Down

0 comments on commit 7be0a71

Please sign in to comment.