EOSIO / eosjs

General purpose library for the EOSIO blockchain.
http://eosio.github.io/eosjs
MIT License
1.43k stars 462 forks source link

query non-exist account name trigger "Internal Service Error"? #259

Closed springrider closed 6 years ago

springrider commented 6 years ago

test code:

let EOS = require("eosjs");
let config = require("./config");
enstance = EOS(config.chainInfo);
enstance.getAccount('nonexistaccount').then(function(result){

}).catch((e) => {

  });

tested both on mainnet and testnet: httpEndpoint: 'http://peer1.eoshuobipool.com:8181', httpEndpoint: 'http://jungle.cryptolions.io:38888',

I am using getAccount to confirm if this account exist. while it exist the function return correct data. but if the account does not exist, it throws an exception, and catch does not work. is this normal behaviour? why not simply return error msg instead?

api < error undefined http://peer1.eoshuobipool.com:8181/v1/chain/get_account {"account_name":"nonexistaccount"} { Error: {"code":500,"message":"Internal Service Error","error":{"code":3010001,"name":"name_type_exception","what":"Invalid name","details":[]}} at /node_modules/eosjs-api/lib/apigen.js:95:23 at at process._tickCallback (internal/process/next_tick.js:188:7) status: 500, statusText: 'Internal Server Error' } (node:88344) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: {"code":500,"message":"Internal Service Error","error":{"code":3010001,"name":"name_type_exception","what":"Invalid name","details":[]}} (node:88344) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

springrider commented 6 years ago

my bad, didn't notice I could turn the error logger down in the config like this: Turn off all error logging: config.logger = {error: null}