Update standard rescued variable names

This commit is contained in:
Thomas Walpole 2019-04-04 12:03:01 -07:00
parent c8d48d41ba
commit 0873c9052d
12 changed files with 30 additions and 30 deletions

View File

@ -300,7 +300,7 @@ module Capybara
synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do
begin
find(:select, from, options)
rescue Capybara::ElementNotFound => select_error
rescue Capybara::ElementNotFound => select_error # rubocop:disable Naming/RescuedExceptionsVariableName
raise if %i[selected with_selected multiple].any? { |option| options.key?(option) }
begin
@ -356,14 +356,14 @@ module Capybara
begin
el = find(selector, locator, options)
el.set(checked)
rescue StandardError => err
raise unless allow_label_click && catch_error?(err)
rescue StandardError => e
raise unless allow_label_click && catch_error?(e)
begin
el ||= find(selector, locator, options.merge(visible: :all))
el.session.find(:label, for: el, visible: true).click unless el.checked? == checked
rescue StandardError # swallow extra errors - raise original
raise err
raise e
end
end
end

View File

@ -81,19 +81,19 @@ module Capybara
timer = Capybara::Helpers.timer(expire_in: seconds)
begin
yield
rescue StandardError => err
rescue StandardError => e
session.raise_server_error!
raise err unless catch_error?(err, errors)
raise e unless catch_error?(e, errors)
if driver.wait?
raise err if timer.expired?
raise e if timer.expired?
sleep(0.01)
reload if session_options.automatic_reload
else
old_base = @base
reload if session_options.automatic_reload
raise err if old_base == @base
raise e if old_base == @base
end
retry
ensure

View File

@ -87,11 +87,11 @@ module Capybara
begin
synchronize { base.style(styles) }
rescue NotImplementedError => err
rescue NotImplementedError => e
begin
evaluate_script(STYLE_SCRIPT, *styles)
rescue Capybara::NotSupportedByDriverError
raise err
raise e
end
end
end
@ -469,8 +469,8 @@ module Capybara
begin
reloaded = query_scope.reload.first(@query.name, @query.locator, @query.options)
@base = reloaded.base if reloaded
rescue StandardError => err
raise err unless catch_error?(err)
rescue StandardError => e
raise e unless catch_error?(e)
end
end
self

View File

@ -83,7 +83,7 @@ module Capybara
matches_system_filters?(node) &&
matches_node_filters?(node, node_filter_errors) &&
matches_filter_block?(node)
rescue *(node.respond_to?(:session) ? node.session.driver.invalid_element_errors : [])
rescue *(node.respond_to?(:session) ? node.session.driver.invalid_element_errors : []) # rubocop:disable Naming/RescuedExceptionsVariableName
false
end

View File

@ -41,8 +41,8 @@ module Capybara
class WrappedElementMatcher < Base
def matches?(actual)
element_matches?(wrap(actual))
rescue Capybara::ExpectationNotMet => err
@failure_message = err.message
rescue Capybara::ExpectationNotMet => e
@failure_message = e.message
false
end

View File

@ -17,8 +17,8 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
def self.load_selenium
require 'selenium-webdriver'
warn "Warning: You're using an unsupported version of selenium-webdriver, please upgrade." if Gem.loaded_specs['selenium-webdriver'].version < Gem::Version.new('3.5.0')
rescue LoadError => err
raise err if err.message !~ /selenium-webdriver/
rescue LoadError => e
raise e unless e.message.match?(/selenium-webdriver/)
raise LoadError, "Capybara's selenium driver is unable to load `selenium-webdriver`, please install the gem and add `gem 'selenium-webdriver'` to your Gemfile if you are using bundler."
end

View File

@ -7,8 +7,8 @@ module Capybara::Selenium::Driver::ChromeDriver
within_given_window(handle) do
begin
super
rescue NoMethodError => err
raise unless err.message =~ /full_screen_window/
rescue NoMethodError => e
raise unless e.message =~ /full_screen_window/
result = bridge.http.call(:post, "session/#{bridge.session_id}/window/fullscreen", {})
result['value']

View File

@ -97,13 +97,13 @@ class Capybara::Selenium::Node < Capybara::Driver::Node
return native.click if click_options.empty?
click_with_options(click_options)
rescue StandardError => err
if err.is_a?(::Selenium::WebDriver::Error::ElementClickInterceptedError) ||
err.message =~ /Other element would receive the click/
rescue StandardError => e
if e.is_a?(::Selenium::WebDriver::Error::ElementClickInterceptedError) ||
e.message.match?(/Other element would receive the click/)
scroll_to_center
end
raise err
raise e
end
def right_click(keys = [], **options)

View File

@ -14,8 +14,8 @@ class Capybara::Selenium::ChromeNode < Capybara::Selenium::Node
def set_file(value) # rubocop:disable Naming/AccessorMethodName
super(value)
rescue ::Selenium::WebDriver::Error::ExpectedError => err
raise ArgumentError, "Selenium < 3.14 with remote Chrome doesn't support multiple file upload" if err.message.match?(/File not found : .+\n.+/m)
rescue ::Selenium::WebDriver::Error::ExpectedError => e
raise ArgumentError, "Selenium < 3.14 with remote Chrome doesn't support multiple file upload" if e.message.match?(/File not found : .+\n.+/m)
raise
end

View File

@ -12,7 +12,7 @@ module Capybara
def request(&block)
ssl? ? https_request(&block) : http_request(&block)
rescue *TRY_HTTPS_ERRORS
rescue *TRY_HTTPS_ERRORS # rubocop:disable Naming/RescuedExceptionsVariableName
res = https_request(&block)
@ssl = true
res

View File

@ -46,9 +46,9 @@ module Capybara
@counter.increment
begin
@extended_app.call(env)
rescue *@server_errors => err
@error ||= err
raise err
rescue *@server_errors => e
@error ||= e
raise e
ensure
@counter.decrement
end

View File

@ -49,7 +49,7 @@ module Capybara
# @return [Boolean] whether this window is the window in which commands are being executed
def current?
@driver.current_window_handle == @handle
rescue @driver.no_such_window_error
rescue @driver.no_such_window_error # rubocop:disable Naming/RescuedExceptionsVariableName
false
end