lib/sendgrid/web/response.rb in sendgrid-web-0.0.7 vs lib/sendgrid/web/response.rb in sendgrid-web-0.1.0
- old
+ new
@@ -12,16 +12,23 @@
#
# @return [bool] True if there were errors found.
def errors?
!parsed_body.nil? &&
parsed_body.is_a?(Hash) &&
- parsed_body.has_key?('errors')
+ (parsed_body.has_key?('errors') ||
+ parsed_body.has_key?('error'))
end
# Fetches an array of error messages from the response.
#
# @return [Array<String>] A list of any error messages.
def error_messages
- errors? ? parsed_body['errors'] : []
+ if errors?
+ errors = Array(parsed_body['errors'])
+ errors << parsed_body['error']
+ errors.compact
+ else
+ []
+ end
end
end