Closed Penderis closed 8 months ago
Are you sure your error is from this? An RPC error for wrong trx_id wouldn't evoke an error to begin with. It will be a normal result because the API will answer with a message.
I suspect the error is from something else that you are not catching.
BTW I did write the above comment after testing your posted code.
Also your format of the API call is wrong. Almost all the API methods other than condenser_api
require an object input and not an array. And API node will return an error telling you this. You can replace account_history_api with condenser_api for quick fix.
Also, the "try catch" won't catch the error thrown in the promise catch in this code. You have to use await/async for your "try catch" to catch the errors from that promise. Try & catch on a promise won't catch the errors happening later without using await/async. That's why there is .catch()
for non async codes.
Also your format of the API call is wrong. Almost all the API methods other than
condenser_api
require an object input and not an array. And API node will return an error telling you this. You can replace account_history_api with condenser_api for quick fix.
It works with that although I did notice I use an object in other ones, not sure how settled on that one but yeah it works. I did run test now using object id:trx and still returns result if correct TRX id. I will test with condenser also. I merely used this one as the simplest way to reproduce the issue.
to be clear the only time I get the uncaught exception is if I expect a rpc error to be returned. But as mentioned in other comment will do more testing or just use fetch where possible. Thank you.
Also, the "try catch" won't catch the error thrown in the promise catch in this code. You have to use await/async for your "try catch" to catch the errors from that promise. Try & catch on a promise won't catch the errors happening later without using await/async. That's why there is
.catch()
for non async codes.
Thank you, I kinda did not click that but the catch from the .then format should though catch the error? I did change it from await just to have both catches there without thinking that it would be pointless. I will setup an await one only for testing.
Are you sure your error is from this? An RPC error for wrong trx_id wouldn't evoke an error to begin with. It will be a normal result because the API will answer with a message.
I suspect the error is from something else that you are not catching.
This could be then from express , although I only get it with hive-tx calls , for thoroughness I will test using fetch directly which I know returns me the rpc error if there is one also but exact call to see which fails. Thank you, I will look into it then sorry for the hassle.
Hi, I might be missing the boat completely and if I am just doing things wrong tips are welcome. I am not however able to catch the axios errors returned from the library via try catch blocks and the promise catch.
Some are hard to test but this is the general error it will always return and then kill the node instance
The simplest way to reproduce is to use a wrong trx id on a account_history.get_transaction call
but it would be the same for trying to use Privatekey.from on a wrong key. I am not sure how to catch these errors to avoid them crashing the instance.