From: Rob Rypka Date: 2005-10-08T01:49:18+09:00 Subject: Re: Customizing Exception, but only when an error is raised On 10/7/05, Berger, Daniel wrote: > I was trying to emulate Perl's $SIG{__DIE__} handler for reports running > via cron where, whenever an error occurred, an email would be sent to me > (or whoever). While I can log errors to a file, I still have to check > the log files periodically to make sure they ran as expected. Every > once in a while something goes awry - network glitch, database glitch - > whatever. I thought cron (at least Vixie cron) sends mail whenever a script has console output. Generally, when I do cron stuff, I only have output if something goes wrong. If Ruby throws an uncaught exception, the output is pretty much what I would want to see anyways. So why aren't you doing that? I think it's easier to have cron handle it rather than have to write code in every script to send mail whenever something bad happens. > The problem, I realized, was that even if I wanted to ignore an error > (or handle it some other way), an email would still be sent out. Now I'm > thinking that maybe I should redefine Kernel#raise instead. You should definately not do that. Robert's first option (begin/rescue/end around everything) is probably the easiest and most direct method, if you can't use cron. -- Rob