Exception: Mailjet::CommunicationError
- Defined in:
- lib/mailjet/exception/errors.rb
Direct Known Subclasses
Constant Summary collapse
- NOCODE =
000
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Attributes inherited from Error
Instance Method Summary collapse
-
#initialize(message = nil, response = nil) ⇒ CommunicationError
constructor
A new instance of CommunicationError.
Constructor Details
#initialize(message = nil, response = nil) ⇒ CommunicationError
Returns a new instance of CommunicationError.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/mailjet/exception/errors.rb', line 49 def initialize( = nil, response = nil) @response = response @code = if response.nil? NOCODE else response.response_status end = begin if response.response_body.present? Yajl::Parser.parse(response.response_body)['ErrorMessage'] else 'Unauthorized' end rescue Yajl::ParseError response.response_body rescue NoMethodError "Unknown API error" rescue 'Unknown API error' end ||= '' ||= '' = + ': ' + super(, response) rescue NoMethodError, JSON::ParserError @code = NOCODE super(, response) end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
45 46 47 |
# File 'lib/mailjet/exception/errors.rb', line 45 def code @code end |