Skip to content

Error Handling

dez1337 edited this page Nov 5, 2017 · 1 revision

Whenever a Steem Node can not handle a request it will return a JPC error object providing the root cause and a lot of additional information.

The following block shows an example.

{
   "id":"3179894233536161001",
   "error":{
      "code":1,
      "message":"3010000 tx_missing_active_auth: missing required active authority\nMissing Active Authority dez1337\n    {\"id\":\"dez1337\",\"auth\":{\"weight_threshold\":1,\"account_auths\":[],\"key_auths\":[[\"STM5eKV7jKw6gFCtUenjQhvkzTA8WZtd6gcHjPHtndt47gEkMGjef\",1]]},\"owner\":{\"weight_threshold\":1,\"account_auths\":[],\"key_auths\":[[\"STM6bvFsAqzNo7VfwjwkPyRCs5ewRo8cN1Hji3fcckUYVYMK1ma5J\",1]]}}\n    th_a  transaction.cpp:157 verify_authority\n\n    {\"ops\":[[\"transfer\",{\"from\":\"dez1337\",\"to\":\"steemj\",\"amount\":\"0.001 STEEM\",\"memo\":\"Test SteemJ\"}]],\"sigs\":[]}\n    th_a  transaction.cpp:172 verify_authority\n\n    {\"*this\":{\"ref_block_num\":34294,\"ref_block_prefix\":3707022213,\"expiration\":\"2016-04-06T08:29:27\",\"operations\":[[\"transfer\",{\"from\":\"dez1337\",\"to\":\"steemj\",\"amount\":\"0.001 STEEM\",\"memo\":\"Test SteemJ\"}]],\"extensions\":[],\"signatures\":[]}}\n    th_a  transaction.cpp:285 verify_authority\n\n    {\"call.method\":\"call\",\"call.params\":[\"database_api\",\"verify_authority\",[{\"ref_block_num\":34294,\"ref_block_prefix\":3707022213,\"expiration\":\"2016-04-06T08:29:27\",\"operations\":[[\"transfer\",{\"from\":\"dez1337\",\"to\":\"steemj\",\"amount\":\"0.001 STEEM\",\"memo\":\"Test SteemJ\"}]],\"extensions\":[],\"signatures\":[]}]]}\n    th_a  websocket_api.cpp:124 on_message",
      "data":{
         "code":3010000,
         "name":"tx_missing_active_auth",
         "message":"missing required active authority",
         "stack":[
            {
               "context":{
                  "level":"error",
                  "file":"transaction.cpp",
                  "line":157,
                  "method":"verify_authority",
                  "hostname":"",
                  "thread_name":"th_a",
                  "timestamp":"2017-11-05T14:32:59"
               },
               "format":"Missing Active Authority ${id}",
               "data":{
                  "id":"dez1337",
                  "auth":{
                     "weight_threshold":1,
                     "account_auths":[

                     ],
                     "key_auths":[
                        [
                           "STM5eKV7jKw6gFCtUenjQhvkzTA8WZtd6gcHjPHtndt47gEkMGjef",
                           1
                        ]
                     ]
                  },
                  "owner":{
                     "weight_threshold":1,
                     "account_auths":[

                     ],
                     "key_auths":[
                        [
                           "STM6bvFsAqzNo7VfwjwkPyRCs5ewRo8cN1Hji3fcckUYVYMK1ma5J",
                           1
                        ]
                     ]
                  }
               }
            },
            {
               "context":{
                  "level":"warn",
                  "file":"transaction.cpp",
                  "line":172,
                  "method":"verify_authority",
                  "hostname":"",
                  "thread_name":"th_a",
                  "timestamp":"2017-11-05T14:32:59"
               },
               "format":"",
               "data":{
                  "ops":[
                     [
                        "transfer",
                        {
                           "from":"dez1337",
                           "to":"steemj",
                           "amount":"0.001 STEEM",
                           "memo":"Test SteemJ"
                        }
                     ]
                  ],
                  "sigs":[

                  ]
               }
            },
            {
               "context":{
                  "level":"warn",
                  "file":"transaction.cpp",
                  "line":285,
                  "method":"verify_authority",
                  "hostname":"",
                  "thread_name":"th_a",
                  "timestamp":"2017-11-05T14:32:59"
               },
               "format":"",
               "data":{
                  "*this":{
                     "ref_block_num":34294,
                     "ref_block_prefix":3707022213,
                     "expiration":"2016-04-06T08:29:27",
                     "operations":[
                        [
                           "transfer",
                           {
                              "from":"dez1337",
                              "to":"steemj",
                              "amount":"0.001 STEEM",
                              "memo":"Test SteemJ"
                           }
                        ]
                     ],
                     "extensions":[

                     ],
                     "signatures":[

                     ]
                  }
               }
            },
            {
               "context":{
                  "level":"warn",
                  "file":"websocket_api.cpp",
                  "line":124,
                  "method":"on_message",
                  "hostname":"",
                  "thread_name":"th_a",
                  "timestamp":"2017-11-05T14:32:59"
               },
               "format":"",
               "data":{
                  "call.method":"call",
                  "call.params":[
                     "database_api",
                     "verify_authority",
                     [
                        {
                           "ref_block_num":34294,
                           "ref_block_prefix":3707022213,
                           "expiration":"2016-04-06T08:29:27",
                           "operations":[
                              [
                                 "transfer",
                                 {
                                    "from":"dez1337",
                                    "to":"steemj",
                                    "amount":"0.001 STEEM",
                                    "memo":"Test SteemJ"
                                 }
                              ]
                           ],
                           "extensions":[

                           ],
                           "signatures":[

                           ]
                        }
                     ]
                  ]
               }
            }
         ]
      }
   }
}

As you can see, the response contains three main fields:

  • The code field contains the actual error code
  • The message field provides you the main reason why the request was not accepted
  • The data field contains additional information about the request and which check at the Steem Node side failed exactly.

Prior to version 0.4.2 it was planned to map the response into a dedicated object including all sub-fields. As you can imagine, the data field is quite dynamic and totally depends on the request that has been made. This behavior makes it nearly impossible to parse it correctly.

To provide a solution for this problem SteemJ in version 0.4.2 and above wraps the error in a SteemResponseException that has the three main fields described above:

  • The code field is an Integer and can be requested using the .getCode() method.
  • The message field is of type String. You can get its value calling the .getMessage() method.
  • The data field is now of type JsonNode - This allows you to analyse and parse it on your own.