Exception: Crawlora::Error

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

Overview

Base class for every error raised by the SDK. Carries the HTTP status, the parsed API ‘code`/body, the raw response text, response headers, and the request id (when request-id tracking is enabled).

Direct Known Subclasses

ClientError, NetworkError, ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status: 0, code: nil, body: nil, raw_body: "", headers: nil, request_id: nil, cause: nil) ⇒ Error

Returns a new instance of Error.



10
11
12
13
14
15
16
17
18
19
# File 'lib/crawlora/errors.rb', line 10

def initialize(message, status: 0, code: nil, body: nil, raw_body: "", headers: nil, request_id: nil, cause: nil)
  super(message)
  @status = status
  @code = code
  @body = body
  @raw_body = raw_body
  @headers = headers ? headers.dup : {}
  @request_id = request_id
  @cause = cause
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



8
9
10
# File 'lib/crawlora/errors.rb', line 8

def body
  @body
end

#causeObject (readonly)

Returns the value of attribute cause.



8
9
10
# File 'lib/crawlora/errors.rb', line 8

def cause
  @cause
end

#codeObject (readonly)

Returns the value of attribute code.



8
9
10
# File 'lib/crawlora/errors.rb', line 8

def code
  @code
end

#headersObject (readonly)

Returns the value of attribute headers.



8
9
10
# File 'lib/crawlora/errors.rb', line 8

def headers
  @headers
end

#raw_bodyObject (readonly)

Returns the value of attribute raw_body.



8
9
10
# File 'lib/crawlora/errors.rb', line 8

def raw_body
  @raw_body
end

#request_idObject (readonly)

Returns the value of attribute request_id.



8
9
10
# File 'lib/crawlora/errors.rb', line 8

def request_id
  @request_id
end

#statusObject (readonly)

Returns the value of attribute status.



8
9
10
# File 'lib/crawlora/errors.rb', line 8

def status
  @status
end