Exception: Ferrum::JavaScriptError

Inherits:
BrowserError show all
Defined in:
lib/ferrum/errors.rb,
sig/ferrum/errors.rbs

Overview

Raised when JavaScript evaluated in the page throws an exception. Carries the JS exception's class name, message, and stack trace.

Instance Attribute Summary collapse

Attributes inherited from BrowserError

#response

Instance Method Summary collapse

Methods inherited from BrowserError

#code, #data

Constructor Details

#initialize(response) ⇒ JavaScriptError

Returns a new instance of JavaScriptError.

Parameters:

  • response (Hash[String, untyped])
  • stack_trace (String, nil)


304
305
306
307
308
309
# File 'lib/ferrum/errors.rb', line 304

def initialize(response)
  @class_name, @message = response["exception"]&.values_at("className", "description")
  @message ||= [response["text"], response.dig("exception", "value")].compact.join(" ")
  @stack_trace = response["stackTrace"]
  super(response.merge("message" => @message))
end

Instance Attribute Details

#class_name ⇒ String? (readonly)

Returns the value of attribute class_name.

Returns:

  • (String, nil)


302
303
304
# File 'lib/ferrum/errors.rb', line 302

def class_name
  @class_name
end

#message ⇒ String (readonly)

Returns the value of attribute message.

Returns:

  • (String)


302
303
304
# File 'lib/ferrum/errors.rb', line 302

def message
  @message
end

#stack_trace ⇒ String? (readonly)

Returns the value of attribute stack_trace.

Returns:

  • (String, nil)


302
303
304
# File 'lib/ferrum/errors.rb', line 302

def stack_trace
  @stack_trace
end