Closed niallel closed 2 years ago
The create
method returns a Promise, so are you catch
ing 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.
The
create
method returns a Promise, so are youcatch
ing 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.
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.
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 :-)
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
{"code": 21216, "message": "Account not allowed to call ***Number Called***", "more_info": "https://www.twilio.com/docs/errors/21216", "status": 400}
Technical details: