Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPC error code #677

Merged
merged 2 commits into from
Jun 2, 2022
Merged

RPC error code #677

merged 2 commits into from
Jun 2, 2022

Conversation

sgerbino
Copy link
Member

@sgerbino sgerbino commented Jun 1, 2022

Resolves #667.

Brief description

Add code to RPC response JSON data.

Checklist

  • I have built this pull request locally
  • I have ran the unit tests locally
  • I have manually tested this pull request
  • I have reviewed my pull request
  • I have added any relevant tests

Demonstration

curl -d '{"jsonrpc":"2.0", "method":"chain.read_contract", "params":{"args":"","contract_id":"z11111111111111111112","entry_point":1249216561}, "id":1}' http://localhost:8080/
{"jsonrpc":"2.0","error":{"code":-32603,"message":"contract does not exist","data":"{\"code\":102}"},"id":1}
...
    invalid_contract             =  102;
...

@mvandeberg
Copy link
Member

Do we want the code to be string json or inline embedded?

"data":"{\"code\":102}"} vs "data":{"code":102}}

@sgerbino
Copy link
Member Author

sgerbino commented Jun 2, 2022

The problem is defining the inline embedded strategy in protobuf. This is a koinos.rpc.error_response which ultimately may or may not be JSON.

Defined here:
https://github.com/koinos/koinos-proto/blob/master/koinos/rpc/rpc.proto

We might be able to define something like this:

message data_record {
   string key = 1;
   google.protobuf.Any value = 2;
}

Then redefine error_response like this:

message error_response {
   string message = 1;
   repeated data_record data = 2;
}

@mvandeberg mvandeberg merged commit 104544e into 666-exceptions Jun 2, 2022
@mvandeberg mvandeberg deleted the 667-rpc-code branch June 2, 2022 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants