Exception: ChartMogul::ChartMogulError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/chartmogul/errors/chartmogul_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_message, http_status: nil, response: nil) ⇒ ChartMogulError

Returns a new instance of ChartMogulError.



7
8
9
10
11
12
13
# File 'lib/chartmogul/errors/chartmogul_error.rb', line 7

def initialize(error_message, http_status: nil, response: nil)
  @error_message = error_message
  @http_status = http_status
  @response = response

  super(build_message)
end

Instance Attribute Details

#error_messageObject (readonly)

Returns the value of attribute error_message.



5
6
7
# File 'lib/chartmogul/errors/chartmogul_error.rb', line 5

def error_message
  @error_message
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



5
6
7
# File 'lib/chartmogul/errors/chartmogul_error.rb', line 5

def http_status
  @http_status
end

#responseObject (readonly)

Returns the value of attribute response.



5
6
7
# File 'lib/chartmogul/errors/chartmogul_error.rb', line 5

def response
  @response
end

Instance Method Details

#build_messageObject



15
16
17
18
19
# File 'lib/chartmogul/errors/chartmogul_error.rb', line 15

def build_message
  status = http_status ? " (HTTP Status: #{http_status})" : ''
  resp = response ? "\nResponse: #{response}" : ''
  "#{error_message}#{status}#{resp}"
end