lib/sendgrid_actionmailer.rb in sendgrid-actionmailer-3.0.0 vs lib/sendgrid_actionmailer.rb in sendgrid-actionmailer-3.0.1
- old
+ new
@@ -278,10 +278,10 @@
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)
end