Class: Selenium::WebDriver::Remote::Response Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | rb/lib/selenium/webdriver/remote/response.rb |
Class Method Summary
- .new(code, payload = nil) ⇒ Response constructor Internal use only
Instance Attribute Summary
Instance Method Summary
- #[](key) Internal use only
- #error Internal use only
- #add_cause(ex, error, backtrace) private Internal use only
- #assert_ok private Internal use only
- #backtrace_from_remote(server_trace) private Internal use only
- #process_error private Internal use only
Constructor Details
.new(code, payload = nil) ⇒ Response
Instance Attribute Details
#code (readonly)
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/response.rb', line 28
attr_reader :code, :payload
#payload (readonly)
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/response.rb', line 28
attr_reader :code, :payload
Instance Method Details
#[](key)
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/response.rb', line 45
def [](key) @payload[key] end
#add_cause(ex, error, backtrace) (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/response.rb', line 59
def add_cause(ex, error, backtrace) cause = Error::WebDriverError.new backtrace = backtrace_from_remote(backtrace) if backtrace.is_a?(Array) cause.set_backtrace(backtrace) raise ex, cause: cause rescue Error.for_error(error) ex end
#assert_ok (private)
# File 'rb/lib/selenium/webdriver/remote/response.rb', line 51
def assert_ok e = error raise e if e return unless @code.nil? || @code >= 400 raise Error::ServerError, self end
#backtrace_from_remote(server_trace) (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/response.rb', line 68
def backtrace_from_remote(server_trace) server_trace.filter_map do |frame| next unless frame.is_a?(Hash) file = frame['fileName'] line = frame['lineNumber'] method = frame['methodName'] class_name = frame['className'] file = "#{class_name}(#{file})" if class_name method = 'unknown' if method.nil? || method.empty? "[remote server] #{file}:#{line}:in `#{method}'" end end
#error
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/response.rb', line 37
def error error, , backtrace = process_error klass = Error.for_error(error) || return ex = klass.new( ) add_cause(ex, error, backtrace) ex end
#process_error (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/response.rb', line 85
def process_error return unless self['value'].is_a?(Hash) [ self['value']['error'], self['value']['message'], self['value']['stacktrace'] ] end