Merge pull request #1149 from josepfo/fix/error-handling-twilio-api-object
Fix/error handling twilio api object
This commit is contained in:
commit
cf512db9e5
3 changed files with 8 additions and 2 deletions
|
|
@ -587,7 +587,7 @@ function formatSubscriberInfo(customer) {
|
|||
const subscriberInfo = customer.subscriberInfo
|
||||
if(!subscriberInfo) return customer
|
||||
const result = subscriberInfo.result
|
||||
if(subscriberInfo.status !== 'successful' || _.isEmpty(result)) return customer
|
||||
if(_.isEmpty(result)) return _.omit(['subscriberInfo'], customer)
|
||||
|
||||
const name = _.get('belongs_to.name')(result)
|
||||
const street = _.get('current_addresses[0].street_line_1')(result)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -745,7 +745,7 @@ const RetrieveDataDialog = ({
|
|||
</DialogContent>
|
||||
{error && (
|
||||
<ErrorMessage className={classes.errorMessage}>
|
||||
Failed to save
|
||||
Failed to fetch additional data
|
||||
</ErrorMessage>
|
||||
)}
|
||||
<DialogActions className={classes.dialogActions}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue