Exception: Easycron::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/easycron/error.rb

Constant Summary collapse

DEFAULT_ERROR_MESSAGE =
'An unexpected error has occurred.'

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#codeObject (readonly)

Returns the value of attribute code.



5
6
7
# File 'lib/easycron/error.rb', line 5

def code
  @code
end

#responseObject (readonly)

Returns the value of attribute response.



4
5
6
# File 'lib/easycron/error.rb', line 4

def response
  @response
end