Exception: Profitwell::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/profitwell.rb,
lib/profitwell/exception.rb

Constant Summary collapse

FAILED_HTTP_STATUSES =
Array(400..599)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Error

Returns a new instance of Error.



7
8
9
10
11
12
13
14
15
16
# File 'lib/profitwell/exception.rb', line 7

def initialize(response)
  # body = JSON.parse(response.body)

  # @code = "#{response[:status]}"
  # @type = body['meta']['error_type']
  # @message = body['meta']['error_message']
  @code = response.code
  @error = FAILED_HTTP_STATUSES.include? response.code
  @message = response
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



3
4
5
# File 'lib/profitwell/exception.rb', line 3

def code
  @code
end

#errorObject (readonly)

Returns the value of attribute error.



3
4
5
# File 'lib/profitwell/exception.rb', line 3

def error
  @error
end

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/profitwell/exception.rb', line 3

def message
  @message
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/profitwell/exception.rb', line 3

def type
  @type
end