Created
May 3, 2015 12:45
-
-
Save JonathanPorta/730a9c9d1265fb5b2dd6 to your computer and use it in GitHub Desktop.
Rescue Exception in Ruby is not a good idea.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Snippet from: http://stackoverflow.com/questions/10048173/why-is-it-bad-style-to-rescue-exception-e-in-ruby?lq=1 | |
Rescuing Exception will resuce all types of exceptions, including signals. | |
loop do | |
begin | |
sleep 1 | |
eval "djsakru3924r9eiuorwju3498 += 5u84fior8u8t4ruyf8ihiure" | |
rescue Exception | |
puts "I refuse to fail or be stopped!" | |
end | |
end | |
[portaj@portaj-air notes]$ ruby ./ruby-exceptions-bad.rb | |
I refuse to fail or be stopped! | |
I refuse to fail or be stopped! | |
I refuse to fail or be stopped! | |
I refuse to fail or be stopped! | |
^V^VI refuse to fail or be stopped! | |
vI refuse to fail or be stopped! | |
vvvvvI refuse to fail or be stopped! | |
I refuse to fail or be stopped! | |
I refuse to fail or be stopped! | |
^CI refuse to fail or be stopped! | |
^CI refuse to fail or be stopped! | |
I refuse to fail or be stopped! | |
I refuse to fail or be stopped! | |
I refuse to fail or be stopped! | |
I refuse to fail or be stopped! | |
^Z | |
[1]+ Stopped ruby ./ruby-exceptions-bad.rb | |
[portaj@portaj-air notes]$ | |
[portaj@portaj-air notes]$ ruby ./ruby-exceptions-bad.rb | |
I refuse to fail or be stopped! | |
^Z | |
[2]+ Stopped ruby ./ruby-exceptions-bad.rb | |
[portaj@portaj-air notes]$ ps aux | grep ruby | |
portaj 14837 0.0 0.3 185740 25032 pts/0 Sl+ 05:13 0:00 ruby /home/portaj/.chefdk/gem/ruby/2.1.0/bin/guard | |
portaj 14843 0.0 0.6 1050060 51172 pts/0 Sl+ 05:13 0:00 ruby /home/portaj/.chefdk/gem/ruby/2.1.0/gems/guard-2.12.5/bin/_guard-core | |
portaj 17680 0.0 0.1 142836 9228 pts/2 Tl 05:39 0:00 ruby ./ruby-exceptions-bad.rb | |
portaj 17688 0.0 0.1 142856 9264 pts/2 Tl 05:40 0:00 ruby ./ruby-exceptions-bad.rb | |
portaj 17712 0.0 0.0 113008 2160 pts/2 S+ 05:40 0:00 grep --color=auto ruby | |
[portaj@portaj-air notes]$ kill 17680 | |
[portaj@portaj-air notes]$ ps aux | grep ruby | |
portaj 14837 0.0 0.3 185740 25032 pts/0 Sl+ 05:13 0:00 ruby /home/portaj/.chefdk/gem/ruby/2.1.0/bin/guard | |
portaj 14843 0.0 0.6 1050060 51172 pts/0 Sl+ 05:13 0:00 ruby /home/portaj/.chefdk/gem/ruby/2.1.0/gems/guard-2.12.5/bin/_guard-core | |
portaj 17680 0.0 0.1 142836 9228 pts/2 Tl 05:39 0:00 ruby ./ruby-exceptions-bad.rb | |
portaj 17688 0.0 0.1 142856 9264 pts/2 Tl 05:40 0:00 ruby ./ruby-exceptions-bad.rb | |
portaj 17720 0.0 0.0 113008 2260 pts/2 S+ 05:41 0:00 grep --color=auto ruby | |
[portaj@portaj-air notes]$ kill -9 17680 | |
[1]- Killed ruby ./ruby-exceptions-bad.rb | |
[portaj@portaj-air notes]$ ps aux | grep ruby | |
portaj 14837 0.0 0.3 185740 25032 pts/0 Sl+ 05:13 0:00 ruby /home/portaj/.chefdk/gem/ruby/2.1.0/bin/guard | |
portaj 14843 0.0 0.6 1050060 51172 pts/0 Sl+ 05:13 0:00 ruby /home/portaj/.chefdk/gem/ruby/2.1.0/gems/guard-2.12.5/bin/_guard-core | |
portaj 17688 0.0 0.1 142856 9264 pts/2 Tl 05:40 0:00 ruby ./ruby-exceptions-bad.rb | |
portaj 17728 0.0 0.0 113008 2248 pts/2 S+ 05:41 0:00 grep --color=auto ruby | |
[portaj@portaj-air notes]$ kill -9 17688 | |
[2]+ Killed ruby ./ruby-exceptions-bad.rb | |
[portaj@portaj-air notes]$ ps aux | grep ruby | |
portaj 14837 0.0 0.3 185740 25032 pts/0 Sl+ 05:13 0:00 ruby /home/portaj/.chefdk/gem/ruby/2.1.0/bin/guard | |
portaj 14843 0.0 0.6 1050060 51172 pts/0 Sl+ 05:13 0:00 ruby /home/portaj/.chefdk/gem/ruby/2.1.0/gems/guard-2.12.5/bin/_guard-core | |
portaj 17738 0.0 0.0 113008 2276 pts/2 S+ 05:41 0:00 grep --color=auto ruby | |
[portaj@portaj-air notes]$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment