Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naming/RescuedExceptionsVariableName does not work with nested rescues #9586

Closed
ldebortoli opened this issue Mar 10, 2021 · 0 comments
Closed

Naming/RescuedExceptionsVariableName does not work with nested rescues #9586

ldebortoli opened this issue Mar 10, 2021 · 0 comments

Comments

@ldebortoli
Copy link

@ldebortoli ldebortoli commented Mar 10, 2021

    rescue StandardError => e1
        begin
            @logger.fatal "EXCEPTION: #{e1}"
        rescue StandardError => e2
            printf "\nFATAL: Several exceptions\n#{e1}\n\n#{e2}\n"
        end
    end

I want to log e1 and e2, but rubocop tranforms this code in

    rescue StandardError => e1
        begin
            @logger.fatal "EXCEPTION: #{e1}"
        rescue StandardError => e1
            printf "\nFATAL: Several exceptions\n#{e1}\n\n#{e1}\n"
        end
    end

so only last exception will be printed, and I can only use one prefered name of exceptions

RuboCop version

$ [bundle exec] rubocop -V
1.11.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.7.2 x86_64-linux)
  - rubocop-rake 0.5.1
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Mar 10, 2021
…ot inner rescues when nested.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Mar 10, 2021
…ot inner rescues when nested.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Mar 10, 2021
…ot register on inner rescues when nested.
dvandersluis added a commit that referenced this issue Mar 10, 2021
[Fix #9586] Update `Naming/RescuedExceptionsVariableName` to not register on inner rescues when nested.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant