Class: CTA::API::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/cta_redux/api/api_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Error

Returns a new instance of Error.



10
11
12
13
# File 'lib/cta_redux/api/api_response.rb', line 10

def initialize(options = {})
  @message = options[:message] || "OK"
  @code = options[:code] ? options[:code].to_i : (@message == "OK" ? 0 : 1)
end

Instance Attribute Details

#codeInteger (readonly)

Returns Error code from the API. Normalized across different CTA APIs, and 0 indicates success.

Returns:

  • (Integer)

    Error code from the API. Normalized across different CTA APIs, and 0 indicates success.



5
6
7
# File 'lib/cta_redux/api/api_response.rb', line 5

def code
  @code
end

#messageString (readonly)

Returns Detailed error message, if any, from the API.

Returns:

  • (String)

    Detailed error message, if any, from the API.



8
9
10
# File 'lib/cta_redux/api/api_response.rb', line 8

def message
  @message
end