twilio / twilio-node

Node.js helper library
MIT License
1.38k stars 500 forks source link

Nothing returned for 21216 errors #760

Closed niallel closed 2 years ago

niallel commented 2 years ago

Issue Summary

When I place a call to a blocked number nothing is returned from client.calls.create. However if I run the same with curl to the API then I get a response.

We need the error to be reported so that we know there is an error.

Steps to Reproduce

  1. Place a call to a blocked number using client.calls.create as in the standard example in the docs here: https://www.twilio.com/docs/voice/make-calls
  2. See that there is no exception created or error returned.
  3. Then place the same call using the curl example from the docs here:4. https://www.twilio.com/docs/voice/make-calls
  4. See the output: {"code": 21216, "message": "Account not allowed to call ***Number Called***", "more_info": "https://www.twilio.com/docs/errors/21216", "status": 400}

Technical details:

iagocalazans commented 2 years ago

The create method returns a Promise, so are you catching the error from the promise, @niallel?

An example code:

// Download the helper library from https://www.twilio.com/docs/node/install
// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = require('twilio')(accountSid, authToken);

client.calls
  .create({
    url: 'http://demo.twilio.com/docs/voice.xml',
    to: '+14155551212',
    from: '+15017122661' 
  })
  .then(call => console.log(call.sid));
  .catch(err => console.log(err)); // Your `catch` block comes here.
niallel commented 2 years ago

The create method returns a Promise, so are you catching the error from the promise, @niallel?

An example code:

// Download the helper library from https://www.twilio.com/docs/node/install
// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = require('twilio')(accountSid, authToken);

client.calls
  .create({
    url: 'http://demo.twilio.com/docs/voice.xml',
    to: '+14155551212',
    from: '+15017122661' 
  })
  .then(call => console.log(call.sid));
  .catch(err => console.log(err)); // Your `catch` block comes here.

This was the first thing I tried, there is nothing caught doing this, or wrapping in try/catch as well.

beebzz commented 2 years ago

Hi @niallel, thanks for submitting an issue. As @iagocalazans outlined, I was able to successfully catch a 21216 error using the provided snippet. If you indeed don't see a call sid or error in your logs, please file a support ticket in order to properly debug this issue.

niallel commented 2 years ago

Thanks, something seems to have changed.

I had opened a case the other week and they came back to say it was fixed.

I just tried again and it works :-)