Exception: ActiveLrs::HttpError

Inherits:
Error
  • Object
show all
Defined in:
lib/active_lrs/error.rb

Overview

Raised when an HTTP request to the LRS fails (non-2xx response).

Provides access to the HTTP status code and response body.

Examples:

raise ActiveLrs::HttpError.new("LRS error", status: 500, body: { "error" => "Internal" })

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, status: nil, body: nil) ⇒ HttpError

Initializes a new HttpError.

Parameters:

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

    Error message

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

    HTTP status code

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

    HTTP response body



30
31
32
33
34
# File 'lib/active_lrs/error.rb', line 30

def initialize(message = nil, status: nil, body: nil)
  super(message || "HTTP request failed")
  @status = status
  @body   = body
end

Instance Attribute Details

#bodyObject? (readonly)

Returns The response body returned by the LRS.

Returns:

  • (Object, nil)

    The response body returned by the LRS



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/active_lrs/error.rb', line 22

class HttpError < Error
  attr_reader :status, :body

  # Initializes a new HttpError.
  #
  # @param message [String, nil] Error message
  # @param status [Integer, nil] HTTP status code
  # @param body [Object, nil] HTTP response body
  def initialize(message = nil, status: nil, body: nil)
    super(message || "HTTP request failed")
    @status = status
    @body   = body
  end
end

#statusInteger? (readonly)

Returns The HTTP status code of the failed request.

Returns:

  • (Integer, nil)

    The HTTP status code of the failed request



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/active_lrs/error.rb', line 22

class HttpError < Error
  attr_reader :status, :body

  # Initializes a new HttpError.
  #
  # @param message [String, nil] Error message
  # @param status [Integer, nil] HTTP status code
  # @param body [Object, nil] HTTP response body
  def initialize(message = nil, status: nil, body: nil)
    super(message || "HTTP request failed")
    @status = status
    @body   = body
  end
end