Class: Esi::ApiError

Inherits:
OAuth2::Error
  • Object
show all
Defined in:
lib/esi/api_error.rb

Overview

ApiError base class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, original_exception = nil) ⇒ Esi::ApiError

Create a new instance of ApiError

Parameters:

  • response (Esi::Response)

    response the response that generated the exception

  • original_exception (ExceptionClass|nil) (defaults to: nil)

    the orginally raised exception



22
23
24
25
26
27
28
29
30
31
# File 'lib/esi/api_error.rb', line 22

def initialize(response, original_exception = nil)
  super(response.original_response)

  @response = response
  @original_exception = original_exception
  @code = response.original_response.status
  @key = response.data[:key]
  @message = response.data[:message].presence || response.data[:error] || original_exception.try(:message)
  @type = response.data[:exceptionType]
end

Instance Attribute Details

#keyString (readonly)

Returns the response.data.

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/esi/api_error.rb', line 15

class ApiError < OAuth2::Error
  attr_reader :response, :key, :message, :type, :original_exception

  # Create a new instance of ApiError
  # @param response [Esi::Response] response the response that generated the exception
  # @param original_exception [ExceptionClass|nil] the orginally raised exception
  # @return [Esi::ApiError] an instance of ApiError
  def initialize(response, original_exception = nil)
    super(response.original_response)

    @response = response
    @original_exception = original_exception
    @code = response.original_response.status
    @key = response.data[:key]
    @message = response.data[:message].presence || response.data[:error] || original_exception.try(:message)
    @type = response.data[:exceptionType]
  end
end

#messageString (readonly)

Returns the response error message.

Returns:

  • (String)

    the response error message



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/esi/api_error.rb', line 15

class ApiError < OAuth2::Error
  attr_reader :response, :key, :message, :type, :original_exception

  # Create a new instance of ApiError
  # @param response [Esi::Response] response the response that generated the exception
  # @param original_exception [ExceptionClass|nil] the orginally raised exception
  # @return [Esi::ApiError] an instance of ApiError
  def initialize(response, original_exception = nil)
    super(response.original_response)

    @response = response
    @original_exception = original_exception
    @code = response.original_response.status
    @key = response.data[:key]
    @message = response.data[:message].presence || response.data[:error] || original_exception.try(:message)
    @type = response.data[:exceptionType]
  end
end

#original_exceptionExceptionClass|nil (readonly)

Returns the orginal raised exception.

Returns:

  • (ExceptionClass|nil)

    the orginal raised exception



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/esi/api_error.rb', line 15

class ApiError < OAuth2::Error
  attr_reader :response, :key, :message, :type, :original_exception

  # Create a new instance of ApiError
  # @param response [Esi::Response] response the response that generated the exception
  # @param original_exception [ExceptionClass|nil] the orginally raised exception
  # @return [Esi::ApiError] an instance of ApiError
  def initialize(response, original_exception = nil)
    super(response.original_response)

    @response = response
    @original_exception = original_exception
    @code = response.original_response.status
    @key = response.data[:key]
    @message = response.data[:message].presence || response.data[:error] || original_exception.try(:message)
    @type = response.data[:exceptionType]
  end
end

#responseEsi::Response (readonly)

Returns the ApiError Response.

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/esi/api_error.rb', line 15

class ApiError < OAuth2::Error
  attr_reader :response, :key, :message, :type, :original_exception

  # Create a new instance of ApiError
  # @param response [Esi::Response] response the response that generated the exception
  # @param original_exception [ExceptionClass|nil] the orginally raised exception
  # @return [Esi::ApiError] an instance of ApiError
  def initialize(response, original_exception = nil)
    super(response.original_response)

    @response = response
    @original_exception = original_exception
    @code = response.original_response.status
    @key = response.data[:key]
    @message = response.data[:message].presence || response.data[:error] || original_exception.try(:message)
    @type = response.data[:exceptionType]
  end
end

#typeString (readonly)

Returns the response.data.

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/esi/api_error.rb', line 15

class ApiError < OAuth2::Error
  attr_reader :response, :key, :message, :type, :original_exception

  # Create a new instance of ApiError
  # @param response [Esi::Response] response the response that generated the exception
  # @param original_exception [ExceptionClass|nil] the orginally raised exception
  # @return [Esi::ApiError] an instance of ApiError
  def initialize(response, original_exception = nil)
    super(response.original_response)

    @response = response
    @original_exception = original_exception
    @code = response.original_response.status
    @key = response.data[:key]
    @message = response.data[:message].presence || response.data[:error] || original_exception.try(:message)
    @type = response.data[:exceptionType]
  end
end