You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that your code is ambiguous, indeed if we us promises we should not have to do a try catch. The code should, if it is in the promised mode, reject the error instead of the throwing it.
A sample of your code:
varwhois=functionwhois(domain,opts,cb){if(typeofdomain!=='string'){thrownewError('Expected a `domain name`');//<< HERE}varcallback;if(typeofopts==='function'){callback=opts;}else{callback=cb;}if(_tldjs.default.tldExists(domain)===false){thrownewError('Invalid a `domain name`');//<< HERE}varencodedDomain="".concat(encodePuny(domain)),promise=requestWhois(encodedDomain,opts);if(callback&&typeofcallback==='function'){promise.then(function(data){returncallback(null,data);}).catch(function(error){returncallback(error,null);});}else{returnpromise;}};
Thanks you!
The text was updated successfully, but these errors were encountered:
alexisvisco
changed the title
Did you know the existence of reject ?
Think of replacing/add throw error with reject
Jan 9, 2019
Hello,
I noticed that your code is ambiguous, indeed if we us promises we should not have to do a try catch. The code should, if it is in the promised mode, reject the error instead of the throwing it.
A sample of your code:
Thanks you!
The text was updated successfully, but these errors were encountered: