twilio / twilio-node

Node.js helper library
MIT License
1.37k stars 495 forks source link

could you provide example of 400-500 error?...what format are these? do these have custom types? #946

Closed carlosLMZarego closed 11 months ago

carlosLMZarego commented 1 year ago

Issue Summary

Hello I need to handle 400-500 errors in my project but I'm not unable to reproduce one of these in order to check the error structure, would you provide me a sample about the fields/properties that these return?...or even better if these return a custom error type could you indicate me what is this? thank you

AsabuHere commented 11 months ago

Hi @carlosLMZarego, Please find a sample instance of 400 errors. Below are the steps I did to generate this error

  1. Installed node via instructions in this repo
  2. Followed these steps to create this resource https://www.twilio.com/docs/sms/a2p-tollfree-messaging-compliance-api-onboarding-guide#2-submit-a-toll-free-verification-request

RestException [Error]: Invalid business country at success (/Users/asabu/di/github/twilio-node/node_modules/twilio/lib/base/Version.js:79:23) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { status: 400, code: 400, moreInfo: 'https://www.twilio.com/docs/errors/400', details: undefined }

Now change business country to "US" and retry, to get another 422 error RestException [Error]: Number not found in Inventory at success (/Users/asabu/di/github/twilio-node/node_modules/twilio/lib/base/Version.js:79:23) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { status: 422, code: 30436, moreInfo: 'https://www.twilio.com/docs/errors/30436', details: undefined } Also removing any of the fields will give a 400 error saying this field is necessary Hope this helps!