Skip to content

Commit

Permalink
Validate error response body for empty string (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrauber authored Apr 3, 2020
1 parent 9009a41 commit 62ccfd4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 3.0.1 - 2020-4-3

### Changes

- Validate error response body for empty string

## 3.0.0 - 2020-3-2

### Removed
Expand All @@ -8,13 +14,13 @@

## 2.6.0 - 2020-1-23

### Chages
### Changes

- Dont send content types with dynamic templates (#69)

## 2.5.0 - 2020-1-21

### Chages
### Changes

- Add personalizations field (#60)

Expand Down
2 changes: 1 addition & 1 deletion lib/sendgrid_actionmailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def perform_send_request(email)
result = client.mail._('send').post(request_body: email.to_json) # ლ(ಠ益ಠლ) that API

if result.status_code && result.status_code.start_with?('4')
message = !!(result.body) ? JSON.parse(result.body).fetch('errors').pop.fetch('message') : 'Sendgrid API Error'
message = !(result.body.empty?) ? JSON.parse(result.body).fetch('errors').pop.fetch('message') : 'Sendgrid API Error'
full_message = "Sendgrid delivery failed with #{result.status_code} #{message}"

settings[:raise_delivery_errors] ? raise(SendgridDeliveryError, full_message) : warn(full_message)
Expand Down
2 changes: 1 addition & 1 deletion lib/sendgrid_actionmailer/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module SendGridActionMailer
VERSION = '3.0.0'.freeze
VERSION = '3.0.1'.freeze
end

0 comments on commit 62ccfd4

Please sign in to comment.