|
NAMEDevel::Confess - Include stack traces on all warnings and errorsSYNOPSISUse on the command line:# Make every warning and error include a full stack trace perl -d:Confess script.pl # Also usable as a module perl -MDevel::Confess script.pl # display warnings in yellow and errors in red perl -d:Confess=color script.pl # set options by environment export DEVEL_CONFESS_OPTIONS='color dump' perl -d:Confess script.pl Can also be used inside a script: use Devel::Confess; use Devel::Confess 'color'; # disable stack traces no Devel::Confess; DESCRIPTIONThis module is meant as a debugging aid. It can be used to make a script complain loudly with stack backtraces when "warn()"ing or "die()"ing. Unlike other similar modules (e.g. Carp::Always), stack traces will also be included when exception objects are thrown.The stack traces are generated using Carp, and will work for all types of errors. Carp's "carp" and "croak" functions will also be made to include stack traces. # it works for explicit die's and warn's $ perl -d:Confess -e 'sub f { die "arghh" }; sub g { f }; g' arghh at -e line 1. main::f() called at -e line 1 main::g() called at -e line 1 # it works for interpreter-thrown failures $ perl -d:Confess -w -e 'sub f { $a = shift; @a = @$a };' \ -e 'sub g { f(undef) }; g' Use of uninitialized value $a in array dereference at -e line 1. main::f(undef) called at -e line 2 main::g() called at -e line 2 Internally, this is implemented with $SIG{__WARN__} and $SIG{__DIE__} hooks. Stack traces are also included if raw non-object references are thrown. This module is compatible with all perl versions back to 5.6.2, without additional prerequisites. It contains workarounds for a number of bugs in the perl interpreter, some of which effect comparatively simpler modules, like Carp::Always. METHODSimport( @options )Enables stack traces and sets options. A list of options to enable can be passed in. Prefixing the options with "no_" will disable them.
The default options can be changed by setting the "DEVEL_CONFESS_OPTIONS" environment variable to a space separated list of options. CONFIGURATION%Devel::Confess::NoTraceClasses or roles added to this hash will not have stack traces attached to them. This is useful for exception classes that provide their own stack traces, or classes that don't cope well with being re-blessed. If Devel::Confess::Builtin is loaded, it will automatically add its supported exception types to this hash.Default Entries:
ACKNOWLEDGMENTSThe idea and parts of the code and documentation are taken from Carp::Always.SEE ALSO
CAVEATSThis module uses several ugly tricks to do its work and surely has bugs.
SUPPORTPlease report bugs via CPAN RT <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Devel-Confess>.AUTHORS
CONTRIBUTORS
COPYRIGHTCopyright (c) 2005-2013 the "AUTHORS" and "CONTRIBUTORS" as listed above.LICENSEThis library is free software and may be distributed under the same terms as perl itself. See <http://dev.perl.org/licenses/>.
Visit the GSP FreeBSD Man Page Interface. |