Skip to content

Instantly share code, notes, and snippets.

@dbalatero
Created November 11, 2009 23:30

Revisions

  1. dbalatero created this gist Nov 11, 2009.
    4 changes: 4 additions & 0 deletions output.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    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
    16 changes: 16 additions & 0 deletions test_splat_with_rescue.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    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)