Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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.


Comment on Re: Catching errors.
Download Code
Re^2: Catching errors.
by Steve_BZ (Hermit) 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.

    Regards

    Steve

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2014-09-15 10:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (146 votes), past polls