Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Catching errors.

by saberworks (Curate)
on Apr 02, 2013 at 19:38 UTC ( #1026751=note: print w/replies, xml ) Need Help??

in reply to Catching errors.

Well, you need to hook into where your app is attempting to do the work in the first place. So figuring out whether help is missing, how do you load the help? If you are loading from a file, you'd have to test if the file exists before you attempt to load it.
if(! -f $expected_help_file) { # send your message }
Same with translation.

For your SQL errors, file errors, sounds like you already have something in mind (custom die function). To trap those as well as any way the program as a whole can die, you can set a SIG die handler, as described in Perl's Warn and Die Signals. This will be run every time something dies (be careful, it also gets run when a die happens in an eval, and there are examples of how to detect and ignore that case). Also you need to be careful not to rely on too much extra stuff in your die handler, the less the better. If your app died because your database connection went away and then your die handler tries to use the db connection to grab a developer email address, it obviously won't work properly.

We also have processes that log any warnings that are emitted and those are looked at on a regular basis as they often alert us to problematic code before it gets out into production.

Replies are listed 'Best First'.
Re^2: Catching errors.
by Steve_BZ (Chaplain) on Apr 12, 2013 at 18:31 UTC

    Hi Saberworks,

    To trap those as well as any way the program as a whole can die, you can set a SIG die handler

    This is exacly what I want. Then I can write a handler that runs on autostart, runs my program, and then when it finishes I can check the exit code for errors.

    I'll try that.



Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1026751]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2021-03-02 08:12 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (41 votes). Check out past polls.