Re: Customizing Exception, but only when an error is raised



> -----Original Message-----
> From: Robert Klemme [mailto:bob.news@xxxxxxx]
> Sent: Friday, October 07, 2005 6:52 AM
> To: ruby-talk ML
> Subject: Re: Customizing Exception, but only when an error is raised

<snip>

> It would be interesting to learn what real world problem
> Daniel wants to solve...
>
> Kind regards
>
> robert

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.

No, I don't want to run a separate program to tail log files looking for
errors. :)

My initial plan (which I had nearly complete) was to do something like
this:

# At the top of your program
require "exception/mail"
Exception.mail_host = "mailhost.foo.com"
Exception.mail_to = "person@xxxxxxx"

Then, whenever an error was raised anywhere in my program an email would
be sent out. There are plenty of other options you could configure,
btw, though the others all have reasonable defaults.

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.

Regards,

Dan



.



Relevant Pages

  • Re: Capture DIE statments from Perl
    ... The log files are on a network, and it's possible that if a ... network glitch occurs, I still may never see my error messages. ... If you can't test your scripts locally, and you don't have access to the error log (not access log) on the server, I would suggest sacking your boss. ...
    (comp.lang.perl.misc)
  • Re: Customizing Exception, but only when an error is raised
    ... > glitch, database glitch - whatever. ... I don't want to run a separate program to tail log files looking ... Kind regards ...
    (comp.lang.ruby)
  • Re: Logging iptables
    ... On Thursday 08 December 2005 11:04 pm, Amadeus W. M. wrote: ... to log all NEW tcp packets on the priviledged ... > Be careful what you log though, because it may fill up your log files. ...
    (Fedora)
  • Re: The best practices to learn Ruby
    ... If so you could tackle some toy projects reading those log files and generating interesting statistics. ... That way you can learn basic file handling and also various methods to parse data (e.g. parsing timestamps and creating Time instances from them, parsing error messages etc.). ... Kind regards ...
    (comp.lang.ruby)
  • Re: Limiting the the size of log files
    ... files by hand backups take ages backing up huge log files. ... management facilities. ...
    (comp.sys.acorn.programmer)