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
|
const subscriberInfo = customer.subscriberInfo
|
||||||
if(!subscriberInfo) return customer
|
if(!subscriberInfo) return customer
|
||||||
const result = subscriberInfo.result
|
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 name = _.get('belongs_to.name')(result)
|
||||||
const street = _.get('current_addresses[0].street_line_1')(result)
|
const street = _.get('current_addresses[0].street_line_1')(result)
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,12 @@ function getLookup (account, number) {
|
||||||
.fetch({ addOns: ['lamassu_ekata'] })
|
.fetch({ addOns: ['lamassu_ekata'] })
|
||||||
})
|
})
|
||||||
.then(info => info.addOns.results['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 => {
|
.catch(err => {
|
||||||
if (_.includes(err.code, BAD_NUMBER_CODES)) {
|
if (_.includes(err.code, BAD_NUMBER_CODES)) {
|
||||||
const badNumberError = new Error(err.message)
|
const badNumberError = new Error(err.message)
|
||||||
|
|
|
||||||
|
|
@ -745,7 +745,7 @@ const RetrieveDataDialog = ({
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
{error && (
|
{error && (
|
||||||
<ErrorMessage className={classes.errorMessage}>
|
<ErrorMessage className={classes.errorMessage}>
|
||||||
Failed to save
|
Failed to fetch additional data
|
||||||
</ErrorMessage>
|
</ErrorMessage>
|
||||||
)}
|
)}
|
||||||
<DialogActions className={classes.dialogActions}>
|
<DialogActions className={classes.dialogActions}>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue