Exception: Easycron::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Easycron::Error
- Defined in:
- lib/easycron/error.rb
Constant Summary collapse
- DEFAULT_ERROR_MESSAGE =
'An unexpected error has occurred.'
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(response = nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(response = nil) ⇒ Error
Returns a new instance of Error.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/easycron/error.rb', line 7 def initialize(response = nil) @response = response if response.nil? super DEFAULT_ERROR_MESSAGE else @code = response.fetch('error', {}).fetch('code', DEFAULT_ERROR_MESSAGE) errmsg = response.fetch('error', {}).fetch('message', DEFAULT_ERROR_MESSAGE) super errmsg end end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/easycron/error.rb', line 5 def code @code end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
4 5 6 |
# File 'lib/easycron/error.rb', line 4 def response @response end |