Merge pull request #580 from embark-framework/gracefullyErrorENS

Gracefully error ens
This commit is contained in:
RJ Catalano 2018-06-26 13:53:38 -05:00 committed by GitHub
commit d86bbe27ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -172,7 +172,13 @@ __embarkENS.resolve = function (name) {
return resolverContract.methods.addr(node).call();
}).then((addr) => {
return addr;
}).catch(err => err);
}).catch((err) => {
if (err == 'Couldn\'t decode addr from ABI: 0x') {
console.log(name + " is not registered");
return "0x";
}
return err;
});
};
__embarkENS.lookup = function (address) {
@ -189,5 +195,11 @@ __embarkENS.lookup = function (address) {
return self.ens.methods.resolver(node).call().then((resolverAddress) => {
let resolverContract = new EmbarkJS.Contract({abi: self.resolverInterface, address: resolverAddress});
return resolverContract.methods.name(node).call();
}).catch(err => err);
}).catch((err) => {
if (err == 'ERROR: The returned value is not a convertible string: 0x0') {
console.log('Address does not resolve to name. Try syncing chain.');
return "";
}
return err;
});
};