From 4e9be1e41880ebfecb05aec8fd59bdfa3c8c6c73 Mon Sep 17 00:00:00 2001 From: Fernando Falci Date: Tue, 8 Jun 2021 21:04:47 +0200 Subject: [PATCH] Better error types --- lib/node/rpc.js | 7 ++++--- lib/wallet/rpc.js | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/node/rpc.js b/lib/node/rpc.js index 7974de14..500de8cd 100644 --- a/lib/node/rpc.js +++ b/lib/node/rpc.js @@ -2212,15 +2212,16 @@ class RPC extends RPCBase { const ns = await this.chain.db.getNameState(nameHash); if (!ns || !ns.owner) - throw new RPCError(errs.TYPE_ERROR, 'Cannot find the name owner.'); + throw new RPCError(errs.MISC_ERROR, 'Cannot find the name owner.'); const coin = await this.chain.getCoin(ns.owner.hash, ns.owner.index); - if (!coin) + if (!coin) { throw new RPCError( - errs.INVALID_ADDRESS_OR_KEY, + errs.DATABASE_ERROR, 'Cannot find the owner\'s address.' ); + } const address = coin.address.toString(this.network); return this.verifyMessage([address, sig, str], help); diff --git a/lib/wallet/rpc.js b/lib/wallet/rpc.js index 6d792606..a142fa21 100644 --- a/lib/wallet/rpc.js +++ b/lib/wallet/rpc.js @@ -1606,15 +1606,16 @@ class RPC extends RPCBase { const ns = await wallet.getNameStateByName(name); if (!ns || !ns.owner) - throw new RPCError(errs.TYPE_ERROR, 'Cannot find the name owner.'); + throw new RPCError(errs.MISC_ERROR, 'Cannot find the name owner.'); const coin = await wallet.getCoin(ns.owner.hash, ns.owner.index); - if (!coin) + if (!coin) { throw new RPCError( - errs.INVALID_ADDRESS_OR_KEY, + errs.DATABASE_ERROR, 'Cannot find the owner\'s address.' ); + } const address = coin.address.toString(this.network); return this.signMessage([address, str], help);