Navigation Menu

Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Remove bad exception handling! #2476

Merged
merged 2 commits into from Oct 25, 2017
Merged

Remove bad exception handling! #2476

merged 2 commits into from Oct 25, 2017

Conversation

gaurish
Copy link
Contributor

@gaurish gaurish commented Aug 2, 2017

Exception is the root of Ruby's exception hierarchy, so when you rescue Exception you rescue from everything, including subclasses such as SyntaxError, LoadError, and Interrupt etc which is a bad idea.

Fix: rescue from StandardError.

Exception is the root of Ruby's exception hierarchy, so when you rescue Exception you rescue from everything, including subclasses such as SyntaxError, LoadError, and Interrupt etc which is a bad idea.

Fix: rescue from StandardError.
@@ -46,7 +46,7 @@ namespace :paperclip do
attachment = instance.send(name)
begin
attachment.reprocess!(*styles)
rescue Exception => e
rescue => e
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be even better to explicitly say rescue StandardError => e

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, this appears to have the same problem as before, it's just now even broader. Agree in principle that rescuing from StandardError would be an improvement unless there's some system reason that we needed to use Exception here. Since it's not covered by a test I think we can assume this was just an oversight.

@@ -46,7 +46,7 @@ namespace :paperclip do
attachment = instance.send(name)
begin
attachment.reprocess!(*styles)
rescue Exception => e
rescue => e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, this appears to have the same problem as before, it's just now even broader. Agree in principle that rescuing from StandardError would be an improvement unless there's some system reason that we needed to use Exception here. Since it's not covered by a test I think we can assume this was just an oversight.

@gaurish
Copy link
Contributor Author

gaurish commented Oct 25, 2017

Updated. Ready for another pass.

@geoffharcourt
Copy link
Contributor

Looks great! Thank you for your contribution.

@geoffharcourt geoffharcourt merged commit c794f6d into thoughtbot:master Oct 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants