Exception: Playwright::Error

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

Direct Known Subclasses

TargetClosedError, TimeoutError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message:, name: nil, stack: nil) ⇒ Error

Returns a new instance of Error.

Parameters:

  • name (String) (defaults to: nil)
  • message (String)
  • stack (Array<String>) (defaults to: nil)


27
28
29
30
31
32
# File 'lib/playwright/errors.rb', line 27

def initialize(message:, name: nil, stack: nil)
  super(message)
  @name = name
  @message = message
  @stack = stack
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



34
35
36
# File 'lib/playwright/errors.rb', line 34

def message
  @message
end

#nameObject (readonly)

Returns the value of attribute name.



34
35
36
# File 'lib/playwright/errors.rb', line 34

def name
  @name
end

#stackObject (readonly)

Returns the value of attribute stack.



34
35
36
# File 'lib/playwright/errors.rb', line 34

def stack
  @stack
end

Class Method Details

.parse(error_payload) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/playwright/errors.rb', line 4

def self.parse(error_payload)
  if error_payload['name'] == 'TimeoutError'
    TimeoutError.new(
      message: error_payload['message'],
      stack: error_payload['stack'],
    )
  elsif error_payload['name'] == 'TargetClosedError'
    TargetClosedError.new(
      message: error_payload['message'],
      stack: error_payload['stack'],
    )
  else
    new(
      name: error_payload['name'],
      message: error_payload['message'],
      stack: error_payload['stack'],
    )
  end
end

Instance Method Details

#log=(log) ⇒ Object



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

def log=(log)
  return unless log
  format_call_log = log.join("\n  - ")
  @message = "#{@message}\nCall log:\n#{format_call_log}\n"
end