Exception: HighLevel::Error

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

Overview

Base class for every error the SDK raises. Carries the HTTP context of the failed request where one is available.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, status: nil, response_body: nil, request_id: nil) ⇒ Error

Returns a new instance of Error.

Parameters:

  • message (String, nil) (defaults to: nil)

    human-readable error message

  • status (Integer, nil) (defaults to: nil)

    HTTP status code

  • response_body (Object, nil) (defaults to: nil)

    parsed response body

  • request_id (String, nil) (defaults to: nil)

    the x-request-id header value



21
22
23
24
25
26
# File 'lib/high_level/errors.rb', line 21

def initialize(message = nil, status: nil, response_body: nil, request_id: nil)
  super(message)
  @status = status
  @response_body = response_body
  @request_id = request_id
end

Instance Attribute Details

#request_idString? (readonly)

Returns the x-request-id response header, when present.

Returns:

  • (String, nil)

    the x-request-id response header, when present



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/high_level/errors.rb', line 14

class Error < StandardError
  attr_reader :status, :response_body, :request_id

  # @param message [String, nil] human-readable error message
  # @param status [Integer, nil] HTTP status code
  # @param response_body [Object, nil] parsed response body
  # @param request_id [String, nil] the +x-request-id+ header value
  def initialize(message = nil, status: nil, response_body: nil, request_id: nil)
    super(message)
    @status = status
    @response_body = response_body
    @request_id = request_id
  end
end

#response_bodyObject? (readonly)

Returns the parsed response body, when available.

Returns:

  • (Object, nil)

    the parsed response body, when available



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/high_level/errors.rb', line 14

class Error < StandardError
  attr_reader :status, :response_body, :request_id

  # @param message [String, nil] human-readable error message
  # @param status [Integer, nil] HTTP status code
  # @param response_body [Object, nil] parsed response body
  # @param request_id [String, nil] the +x-request-id+ header value
  def initialize(message = nil, status: nil, response_body: nil, request_id: nil)
    super(message)
    @status = status
    @response_body = response_body
    @request_id = request_id
  end
end

#statusInteger? (readonly)

Returns the HTTP status code, when the error came from a response.

Returns:

  • (Integer, nil)

    the HTTP status code, when the error came from a response



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/high_level/errors.rb', line 14

class Error < StandardError
  attr_reader :status, :response_body, :request_id

  # @param message [String, nil] human-readable error message
  # @param status [Integer, nil] HTTP status code
  # @param response_body [Object, nil] parsed response body
  # @param request_id [String, nil] the +x-request-id+ header value
  def initialize(message = nil, status: nil, response_body: nil, request_id: nil)
    super(message)
    @status = status
    @response_body = response_body
    @request_id = request_id
  end
end