From: Anton Aylward Date: 2007-12-07T03:58:57+09:00 Subject: Custom error handling question I'm trying to port something I've done in Perl to Ruby and am getting myself confused, or perhaps drowned in details between the various files. I'm trying to write a custom error handler class. The documentation tells me that you can extend the Error class with a custom one that does more. So I started with class CustomError < StandardError def initialise(arg1, arg2, arg3, *args) ..... ..... end def handle( opt1, opt2, opt3) .... .... end end I then had a wrapper that wrapped around the code that did the work. def dothefanango(context, &codeblock) oops = CustomError.new( context, stuff, more_stuff) begin yield context rescue CustomError ... oops.handle(......) .... rescue CustomError other than the one above ....... rescue StandardError .... .... else .... end In principle, all well and good. In practice the details are killing me. The pickaxe book says that the rescue clause can have parameters, but I'm also concerned with the 'raise' passing back information - more than just a string. I'm drowning in the details and don't know what to try and experiment with. Any advice would be appreciated. -- This is not a novel to be tossed aside lightly. It should be thrown with great force. -- Dorothy Parker