mirror of https://github.com/embarklabs/embark.git
catch errors and handle gracefully in ENS
This commit is contained in:
parent
d12271e85d
commit
1d7851e2ff
|
@ -14,6 +14,7 @@ __embarkENS.resolverInterface = [
|
|||
}
|
||||
],
|
||||
"name": "addr",
|
||||
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
|
@ -172,7 +173,14 @@ __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";
|
||||
} else {
|
||||
return err;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
__embarkENS.lookup = function (address) {
|
||||
|
@ -189,5 +197,12 @@ __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 "";
|
||||
} else {
|
||||
return err;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue