class RightApi::ApiException

Public Class Methods

new(*args) click to toggle source

Create a new ApiError. This accepts a parameter glob because this type is aliased to a removed exception type that took only one initializer argument: the response object. This type prefers two arguments: the request and response objects. If you pass only one argument, it is taken to be the response.

Calls superclass method
# File lib/right_api_client/errors.rb, line 9
def initialize(*args)
  case args.size
  when 1
    # Compatible with RightApi::Exceptions::ApiException (from 1.5.9 of the gem)
    @request, @response = nil, args[0]
  when 2
    # Normal/preferred format
    @request, @response = args[0], args[1]
  else
    raise ArgumentError, "wrong number of arguments (#{args.size} for 1 or 2)"
  end

  super(
    prefix +
    "HTTP Code: #{@response.code.to_s}, " +
    "Response body: #{@response.body}")
end

Public Instance Methods

prefix() click to toggle source
# File lib/right_api_client/errors.rb, line 27
def prefix

  'Error: '
end
response_code() click to toggle source

Get the HTTP response code that triggered this error.

@return [Integer] the response code

# File lib/right_api_client/errors.rb, line 36
def response_code
  @response.code
end