Skip to content

Commit

Permalink
Fix error handling path in twilio
Browse files Browse the repository at this point in the history
  • Loading branch information
spakanati committed Oct 14, 2016
1 parent e214d49 commit d4a8752
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/server/api/lib/twilio.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { getLastMessage } from './message-sending'
import faker from 'faker'

let twilio = null
const MAX_SEND_ATTEMPTS = 5

if (process.env.TWILIO_API_KEY && process.env.TWILIO_AUTH_TOKEN) {
twilio = Twilio(process.env.TWILIO_API_KEY, process.env.TWILIO_AUTH_TOKEN)
}
Expand Down Expand Up @@ -111,7 +113,7 @@ async function sendMessage(message) {
messageToSave.service_messages.push(response || null)

// TODO: This copies nexmo code nearly exactly
const hasError = !!messageToSave.error_code
const hasError = !!response.error_code
if (hasError) {
if (messageToSave.service_messages.length >= MAX_SEND_ATTEMPTS) {
messageToSave.send_status = 'ERROR'
Expand Down

0 comments on commit d4a8752

Please sign in to comment.