Created
November 11, 2009 23:30
-
-
Save dbalatero/232430 to your computer and use it in GitHub Desktop.
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
RESCUED TYPE A | |
RESCUED TYPE B | |
test_splat_with_rescue.rb:8:in `a': ohhhhh we raised a type C (C) | |
from test_splat_with_rescue.rb:16 |
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
class A < StandardError; end | |
class B < StandardError; end | |
class C < StandardError; end | |
def a(klass) | |
types = [A, B] | |
begin | |
raise klass, "ohhhhh we raised a type #{klass.to_s}" | |
rescue *types => error | |
puts "RESCUED TYPE #{klass.to_s}" | |
end | |
end | |
a(A) | |
a(B) | |
a(C) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment