Better error types
This commit is contained in:
parent
8767e9b786
commit
4e9be1e418
2 changed files with 8 additions and 6 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue