From: Dan Doel Date: 2004-04-05T00:41:03+09:00 Subject: Re: Any chance to see Exception#resume in Ruby2 ? This probably isn't the safest way to do it, but it works. Note that if your arguments to #raise are wrong, and it throws an ArgumentError, that will get wrapped with a #resume method. It's probably safer try and handle all the possible argument combinations to #raise properly, but this way is a lot easier for a proof-of-concept. Enjoy. - Dan [dolio 11:35:18 ~] $ cat prac.rb #!/usr/bin/ruby def recoverable_raise(*args) raise *args rescue Exception => e callcc do |cc| scls = class << e; self; end scls.send(:define_method, :resume, lambda { cc.call }) raise end end begin puts "foo" recoverable_raise "baz" puts "bar" rescue Exception => e p e e.resume end [dolio 11:35:39 ~] $ ./prac.rb foo # bar [dolio 11:36:00 ~] $