On Thu, 10 Nov 2005, lroland / gmail.com wrote: > I am moving a rather big Perl application to Ruby, due to the nasty way > Perl (un)handles exceptions we originally used log4perl (a log4j/log4r > like logging facility) heavily in a 'log and recover' like manner. General Rule of Thumb... Never catch an exception you don't know how to handle. If you can't actually make things better by catching it, don't. Let it go up until somebody higher up does. A commonish idiom I will use is catch and rethrow. If for example, at an intermediate level I have more information about what was happening, I will catch and add that info to the exception or perhaps create a new and different one (but including the backtrace info from the first.) And then raise that for a higher level to catch. So in my scripts any mucks ups by the user unwinds accumulating info until it can present a very relevant and accurate error message to the user. If it's a bug it unwinds to a catcher of last resort that explicitly states, "Sorry, it's John's fault" and then dumps a (very) detailed backtrace. 99% of the time I can fix the bug straight off one of those reports. Except in a handler of last resort, always raise and rescue the most explicit and least general exception you can. Even if you have to spin a new Exception subclass for the occasion. Failure to do so will mask bugs and render your code inflexible. John Carter Phone : (64)(3) 358 6639 Tait Electronics Fax : (64)(3) 359 4632 PO Box 1645 Christchurch Email : john.carter / tait.co.nz New Zealand Carter's Clarification of Murphy's Law. "Things only ever go right so that they may go more spectacularly wrong later." From this principle, all of life and physics may be deduced.