Exception: Capybara::Lightpanda::BrowserError

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

Overview

Base class for any error originating from a CDP response or live browser state. Lets callers ‘rescue BrowserError` to catch the whole CDP family in one go (mirrors ferrum’s hierarchy). Accepts either a CDP error hash (‘=> …, “code” => …`) or a plain string for callsites that raise with a literal message.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_or_message = nil) ⇒ BrowserError

Returns a new instance of BrowserError.



22
23
24
25
26
27
28
29
30
# File 'lib/capybara/lightpanda/errors.rb', line 22

def initialize(response_or_message = nil)
  if response_or_message.is_a?(Hash)
    @response = response_or_message
    super(response_or_message["message"])
  else
    @response = nil
    super
  end
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



20
21
22
# File 'lib/capybara/lightpanda/errors.rb', line 20

def response
  @response
end

Instance Method Details

#codeObject



32
33
34
# File 'lib/capybara/lightpanda/errors.rb', line 32

def code
  @response&.dig("code")
end

#dataObject



36
37
38
# File 'lib/capybara/lightpanda/errors.rb', line 36

def data
  @response&.dig("data")
end