Skip to content

Commit

Permalink
Merge pull request #10887 from dvandersluis/lint/shadowed-exception
Browse files Browse the repository at this point in the history
Improve documentation for `Lint/ShadowedException`
  • Loading branch information
koic committed Aug 9, 2022
2 parents f304479 + de7a7d4 commit eaec469
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/rubocop/cop/lint/shadowed_exception.rb
Expand Up @@ -7,6 +7,14 @@ module Lint
# less specific exception being rescued before a more specific
# exception is rescued.
#
# An exception is considered shadowed if it is rescued after its
# ancestor is, or if it and its ancestor are both rescued in the
# same `rescue` statement. In both cases, the more specific rescue is
# unnecessary because it is covered by rescuing the less specific
# exception. (ie. `rescue Exception, StandardError` has the same behavior
# whether `StandardError` is included or not, because all `StandardError`s
# are rescued by `rescue Exception`).
#
# @example
#
# # bad
Expand All @@ -19,6 +27,13 @@ module Lint
# handle_standard_error
# end
#
# # bad
# begin
# something
# rescue Exception, StandardError
# handle_error
# end
#
# # good
#
# begin
Expand Down

0 comments on commit eaec469

Please sign in to comment.