Skip to content

Commit 62ccfd4

Browse files
authored
Validate error response body for empty string (#75)
1 parent 9009a41 commit 62ccfd4

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## 3.0.1 - 2020-4-3
4+
5+
### Changes
6+
7+
- Validate error response body for empty string
8+
39
## 3.0.0 - 2020-3-2
410

511
### Removed
@@ -8,13 +14,13 @@
814

915
## 2.6.0 - 2020-1-23
1016

11-
### Chages
17+
### Changes
1218

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

1521
## 2.5.0 - 2020-1-21
1622

17-
### Chages
23+
### Changes
1824

1925
- Add personalizations field (#60)
2026

lib/sendgrid_actionmailer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def perform_send_request(email)
280280
result = client.mail._('send').post(request_body: email.to_json) # ლ(ಠ益ಠლ) that API
281281

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

286286
settings[:raise_delivery_errors] ? raise(SendgridDeliveryError, full_message) : warn(full_message)

lib/sendgrid_actionmailer/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module SendGridActionMailer
2-
VERSION = '3.0.0'.freeze
2+
VERSION = '3.0.1'.freeze
33
end

0 commit comments

Comments
 (0)