Merge pull request #585 from embark-framework/gracefullyErrorENS

small correction
This commit is contained in:
RJ Catalano 2018-06-26 15:19:02 -05:00 committed by GitHub
commit 518e96585c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -153,6 +153,9 @@ __embarkENS.resolverInterface = [
}
];
const NoDecodeAddrError = 'Error: Couldn\'t decode address from ABI: 0x';
const NoDecodeStringError = 'ERROR: The returned value is not a convertible string: 0x0';
__embarkENS.setProvider = function (config) {
const self = this;
EmbarkJS.onReady(() => {
@ -173,7 +176,7 @@ __embarkENS.resolve = function (name) {
}).then((addr) => {
return addr;
}).catch((err) => {
if (err == 'Couldn\'t decode addr from ABI: 0x') {
if (err === NoDecodeAddrError) {
console.log(name + " is not registered");
return "0x";
}
@ -196,7 +199,7 @@ __embarkENS.lookup = function (address) {
let resolverContract = new EmbarkJS.Contract({abi: self.resolverInterface, address: resolverAddress});
return resolverContract.methods.name(node).call();
}).catch((err) => {
if (err == 'ERROR: The returned value is not a convertible string: 0x0') {
if (err === NoDecodeStringError || err === NoDecodeAddrError) {
console.log('Address does not resolve to name. Try syncing chain.');
return "";
}