|
NAMENo::Worries::Die - error handling without worriesSYNOPSISuse No::Worries::Die qw(dief handler); open($fh, "<", $path) or dief("cannot open(%s): %s", $path, $!); ... not reached in case of failure ... $ ./myprog myprog: cannot open(foo): No such file or directory $ NO_WORRIES=confess ./myprog myprog: cannot open(foo): No such file or directory at myprog line 16 main::test() called at ./myprog line 19 DESCRIPTIONThis module eases error handling by providing a convenient wrapper around die() with sprintf()-like API. dief() is to die() what printf() is to print() with, in addition, the trimming of leading and trailing spaces.It also provides a handler for die() that prepends a prefix ($No::Worries::Die::Prefix) to all errors. It also uses the "NO_WORRIES" environment variable to find out if Carp's croak() or confess() should be used instead of die(). Finally, the wrapper can be told to also log errors to syslog (see $No::Worries::Die::Syslog). This handler can be installed simply by importing it: use No::Worries::Die qw(dief handler); Alternatively, it can be installed "manually": use No::Worries::Die qw(dief); $SIG{__DIE__} = \&No::Worries::Die::handler; FUNCTIONSThis module provides the following functions (none of them being exported by default):
GLOBAL VARIABLESThis module uses the following global variables (none of them being exported):
ENVIRONMENT VARIABLESThis module uses the "NO_WORRIES" environment variable to control how errors should be reported. Supported values are:
SEE ALSOCarp, No::Worries, No::Worries::Syslog, No::Worries::Warn.AUTHORLionel Cons <http://cern.ch/lionel.cons>Copyright (C) CERN 2012-2019
Visit the GSP FreeBSD Man Page Interface. |