use No::Die; Some::Function::that_dies() or warn "It tried to die with msg: $DIE\n";
Only let modules die when you say it's OK.
Tired of using eval as a straightjacket on modules that have as much interest in life as chronically depressed lemmings? Now there's a 24 hour suicide watch in No::Die. Only modules you permit to die may - the rest will just have to live with it. Their distress wil be noted in an error variable and undef will be returned. The ultimate decision of life and death will be left to your application.
By default, only die calls that are issued from the same package and the same file that the call to use No::Die was in, will be actually allowed to be executed.
use No::Die
You can override this by supplying extra file- and/or packagenames that may also call die and have their request honoured.
All functions that call die() and are not allowed to, will have undef returned to them. The error they attempted to throw will be stored in an exported variable called $DIE.
die()
$DIE
When running under warnings, No::Die will issue a warning for all unauthorized calls to die() so you may inspect which unruly module is attempting to take it's own life in your program.
No::Die
Some modules do not conceive the possibillity that a die might not be honoured and do not explicitly end their subroutine, but do something like this:
sub foo { ... die 'oops' if $condition; # go on with stuff ... }
The execution after the call to die will now happen, since the module in question wasn't allowed to call die() to begin with.
Apparently some people forget this: Carp::croak and Carp::confess also use die() under the hood, so they'll be affected as well by the use of No::Die.
Jos Boumans kane@cpan.org
This module is copyright (c) 2003 Jos Boumans <kane@cpan.org>. All rights reserved.
This library is free software; you may redistribute and/or modify it under the same terms as Perl itself.
To install No::Die, copy and paste the appropriate command in to your terminal.
cpanm
cpanm No::Die
CPAN shell
perl -MCPAN -e shell install No::Die
For more information on module installation, please visit the detailed CPAN module installation guide.