Exception: BrightData::HTTPError

Inherits:
Error
  • Object
show all
Defined in:
lib/brightdata/errors.rb

Overview

Base class for transport-level errors.

Direct Known Subclasses

RateLimitError, ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status: nil, body: nil, response: nil) ⇒ HTTPError

Returns a new instance of HTTPError.

Parameters:

  • message (String)

    human-readable error message

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

    HTTP status, or nil if unavailable

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

    raw response body

  • response (Net::HTTPResponse, nil) (defaults to: nil)

    raw Net::HTTP response



35
36
37
38
39
40
# File 'lib/brightdata/errors.rb', line 35

def initialize(message, status: nil, body: nil, response: nil)
  super(message)
  @status = status
  @body = body
  @response = response
end

Instance Attribute Details

#bodyString? (readonly)

Returns raw response body.

Returns:

  • (String, nil)

    raw response body



26
27
28
# File 'lib/brightdata/errors.rb', line 26

def body
  @body
end

#responseNet::HTTPResponse? (readonly)

Returns raw Net::HTTP response.

Returns:

  • (Net::HTTPResponse, nil)

    raw Net::HTTP response



29
30
31
# File 'lib/brightdata/errors.rb', line 29

def response
  @response
end

#statusInteger? (readonly)

Returns HTTP status, or nil if the request never completed.

Returns:

  • (Integer, nil)

    HTTP status, or nil if the request never completed



23
24
25
# File 'lib/brightdata/errors.rb', line 23

def status
  @status
end