fix: do not store failed twilio api responses on db

This commit is contained in:
José Oliveira 2022-03-08 17:41:34 +00:00
parent 348260931e
commit 96bad31317
2 changed files with 9 additions and 3 deletions

View file

@ -45,6 +45,12 @@ function getLookup (account, number) {
.fetch({ addOns: ['lamassu_ekata'] })
})
.then(info => info.addOns.results['lamassu_ekata'])
.then(info => {
if (info.status !== 'successful') {
throw new Error(`Twilio error: ${info.message}`)
}
return info
})
.catch(err => {
if (_.includes(err.code, BAD_NUMBER_CODES)) {
const badNumberError = new Error(err.message)