Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

DAWN 515 - Improving EOSIOC: error that is received from RPC API Call #1477

Merged
merged 2 commits into from
Feb 27, 2018

Conversation

andriantolie
Copy link
Contributor

@andriantolie andriantolie commented Feb 26, 2018

This is the first attempt of improving error that EOSIOC receives from RPC API call to be more verbose and meaningful.

This pull request changes the error sent by RPC API call from:

{
  "code": 500,
  "message": "Internal Service Error",
  "details": "3040000 action_validate_exception: message validation exception\nCannot create account named eosio, as that name is already taken\n    {\"name\":\"eosio\"}\n    thread-0  eosio_contract.cpp:79 apply_eosio_newaccount\n\n    {\"create\":{\"creator\":\"eosio\",\"name\":\"eosio\",\"owner\":{\"threshold\":1,\"accounts\":[],\"keys\":[{\"key\":\"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV\",\"weight\":1}]},\"active\":{\"threshold\":1,\"accounts\":[],\"keys\":[{\"key\":\"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV\",\"weight\":1}]},\"recovery\":{\"threshold\":1,\"accounts\":[{\"permission\":{\"actor\":\"eosio\",\"permission\":\"active\"},\"weight\":1}],\"keys\":[]}}}\n    thread-0  eosio_contract.cpp:104 apply_eosio_newaccount\n\n    {\"_pending_console_output.str()\":\"\"}\n    thread-0  apply_context.cpp:32 exec_one\n\n    {\"trx\":{\"signatures\":[\"EOSJuWLunf2SvsSppwNQLNRRvBWTuqUPbjiZwU46f2p1ByW1A5KSVHBYvBe129uZ3WjuynoxXewbp3iHnTzRRXvistMugaAa5\"],\"compression\":\"none\",\"data\":\"99d9935a0000ed0000b4ed210000000000010000000000ea305500409e9a2264b89a010000000000ea305500000000a8ed32327c0000000000ea30550000000000ea30550100000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf01000100000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf010001000000010000000000ea305500000000a8ed3232010000\"}}\n    thread-0  chain_controller.cpp:256 push_transaction"
}

to:

{
  "code": 500,
  "message": "Internal Service Error",
  "error": {
    "code": 3040000,
    "name": "action_validate_exception",
    "message": "message validation exception",
    "details": "Cannot create account named eosio, as that name is already taken",
    "stack_trace": [
      {
        "level": "error",
        "file": "eosio_contract.cpp",
        "line": 79,
        "method": "apply_eosio_newaccount",
        "hostname": "",
        "thread_name": "thread-0",
        "timestamp": "2018-02-26T10:06:26.728"
      },
      {
        "level": "warn",
        "file": "eosio_contract.cpp",
        "line": 104,
        "method": "apply_eosio_newaccount",
        "hostname": "",
        "thread_name": "thread-0",
        "timestamp": "2018-02-26T10:06:26.728"
      },
      {
        "level": "warn",
        "file": "apply_context.cpp",
        "line": 32,
        "method": "exec_one",
        "hostname": "",
        "thread_name": "thread-0",
        "timestamp": "2018-02-26T10:06:26.728"
      },
      {
        "level": "warn",
        "file": "chain_controller.cpp",
        "line": 256,
        "method": "push_transaction",
        "hostname": "",
        "thread_name": "thread-0",
        "timestamp": "2018-02-26T10:06:26.729"
      }
    ]
  }
}

(stack trace is limited to 10)

And change the eosioc displayed error message from:
screen shot 2018-02-26 at 5 56 44 pm
to:
screen shot 2018-02-26 at 6 04 27 pm

This PR currently only improves one error message returned by RPC API call. If there is no problem with this PR and it gets merged, another PR will be made to improve the remaining error messages in the list https://docs.google.com/spreadsheets/d/1ccnjnDbImkLaEG4qjD6VdjTJjwd5RRZPaGBp04rRqII/edit#gid=83425241.

@andriantolie andriantolie requested review from wanderingbort and heifner and removed request for wanderingbort February 26, 2018 10:19
@@ -1006,7 +1008,7 @@ int main( int argc, char** argv ) {
}
} else {
// attempt to extract the error code if one is present
if (verbose_errors || !print_help_text(e)) {
if (verbose_errors || !print_help_text(e, show_error_trace)) {
elog("Failed with error: ${e}", ("e", verbose_errors ? e.to_detail_string() : e.to_string()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any downside to unifying verbose_errors and show_error_trace? It seems like in cases where the help text is present, verbose_errors just forces the old style ugly printing. Semantically, "verbose" to me could imply traces.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually... you are right. I don't really pay attention on what "verbose_errors" had been printing until now and now I notice that the information is redundant with the updated print_help_text function.
Thanks for pointing out!

PR Updated for this purpose, also I modify print_help_function to print more information when it is verbose.

Now it looks like this
screen shot 2018-02-27 at 6 28 09 pm

@wanderingbort wanderingbort merged commit d8db1d3 into master Feb 27, 2018
@wanderingbort wanderingbort deleted the DAWN-513 branch February 27, 2018 13:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants