clearbit/clearbit-node

NameToDomain - Can't catch NameToDomain.NotFoundError

Closed this issue ยท 8 comments

Hi,

I'm trying to do a filtered catch as show in the documentation. It doesn't seem to work with NameToDomain.NotFoundError.

var NameToDomain = clearbit.NameToDomain;
NameToDomain.find({name: 'UberrebU'})
  .then(function (result) {
    console.log('Domain: ', result.domain);
  })
  .catch(NameToDomain.NotFoundError, function (err) {
    // NEVER GET HERE!
    console.log(err); // Domain could not be found
  })
  .catch(function (err) {
    console.log(err);
    console.log('Bad/invalid request, unauthorized, Clearbit error, or failed request');
  });

When the domain can not be found, it ends up in the last catch block with the following error:

{ ClearbitError: Not Found
    at ClearbitClient.<anonymous> (/Users/brandon/code/new-bonfire-organization/node_modules/clearbit/src/client.js:82:22)
    at ClearbitClient.tryCatcher (/Users/brandon/code/new-bonfire-organization/node_modules/clearbit/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/Users/brandon/code/new-bonfire-organization/node_modules/clearbit/node_modules/bluebird/js/main/promise.js:508:31)
    at Promise._settlePromiseAt (/Users/brandon/code/new-bonfire-organization/node_modules/clearbit/node_modules/bluebird/js/main/promise.js:584:18)
    at Promise._settlePromises (/Users/brandon/code/new-bonfire-organization/node_modules/clearbit/node_modules/bluebird/js/main/promise.js:700:14)
    at Async._drainQueue (/Users/brandon/code/new-bonfire-organization/node_modules/clearbit/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/Users/brandon/code/new-bonfire-organization/node_modules/clearbit/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues (/Users/brandon/code/new-bonfire-organization/node_modules/clearbit/node_modules/bluebird/js/main/async.js:15:14)
    at runCallback (timers.js:574:20)
    at tryOnImmediate (timers.js:554:5)
    at processImmediate [as _immediateCallback] (timers.js:533:5)
  message: 'Not Found',
  type: 'unknown',
  body: '{\n  "type": "unknown_record",\n  "message": "Unknown company."\n}',
  statusCode: 404 }

Hey @BrandonNoad would you mind including your environment details so I can look into this further? Thanks!

Using node v6.11.5 (npm v3.10.10) on OS X.

Thanks Brandon! Will look into this shortly ๐Ÿ‘

Hey @BrandonNoad, I traced the issue back to how we were sending through upstream errors. Long story short, they should now be in the correct format. Would you mind being a second set of eyes and checking to see if this has fixed the issue?

Yes. I can take a look at it. Is there a branch I can checkout?

Nope! Because it was to do with how we were rendering error responses there are no changes to the repo, but rather to our upstream APIs.

I've tested, but would be great if you could verify! ๐Ÿ‘

Seems to be working now ๐Ÿ˜„ Thanks!

Thanks for verifying! โค๏ธ