Skip to content

Commit

Permalink
Add an example how to handle Twilio error
Browse files Browse the repository at this point in the history
  • Loading branch information
bibstha committed May 19, 2024
1 parent f4e8aa9 commit 597e37a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/delivery_methods/twilio_messaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ deliver_by :twilio_messaging do |config|
end
```

## Error Handling

```ruby
deliver_by :twilio_messaging do |config|
config.error_handler = lambda do |twilio_error_response|
error_hash = JSON.parse(twilio_error_response.body)
case error_hash["code"]
when 21211
# The 'To' number is not a valid phone number.
# Write your error handling code
else
raise "Unhandled Twilio error: #{error_hash}"
end
end
end
```

## Options

* `json` - *Optional*
Expand Down

0 comments on commit 597e37a

Please sign in to comment.