From: Logan Capaldo Date: 2004-11-03T11:20:20+09:00 Subject: Programmatically and dynamically catching exceptions Allright here was my idea which seems to have been shattered by the realities of Ruby. I was thinking of a class called Try. You would do something like class Try ... end tryblock = Try.new { #This block would normally be wrapped in a begin...rescue } tryblock.add_exhandler(:SomeException) { |ex| some_code } tryblock.execute #or possibly tryblock.call ? Basically the idea was going to be you could subclass Try and provide default sensible handling of your Exceptions (if you were writing a library for instance) . Users could then then wrap it in a begin...rescue block to catch other exceptions or use add_exhandler to overide the default handler. (Possibly provide a way to get the old handler and and use it in the new). my idea was going to be that I could do something like begin user_proc.call [SomeEx1, SomeEx2, etc..].each do |ex| rescue ex => e handler_hash[ex].call(e) end Unfortunately the syntax doesn;t seem to allow for this. Am I missing something? is this just a really bad idea?