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 ({"message" => ..., "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.



30
31
32
33
34
35
36
37
38
# File 'lib/capybara/lightpanda/errors.rb', line 30

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.



28
29
30
# File 'lib/capybara/lightpanda/errors.rb', line 28

def response
  @response
end

Instance Method Details

#codeObject



40
41
42
# File 'lib/capybara/lightpanda/errors.rb', line 40

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

#dataObject



44
45
46
# File 'lib/capybara/lightpanda/errors.rb', line 44

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