| Module Info
| Add a review of Carp-Always
This module works well for string exceptions (e.g. die "some message"), but for ref/object exceptions (e.g. die [404,"Not found"] or die $some_object) it will simply print/return the ref/object and thus no stack trace information is produced.
See also Devel::Confess, which can handle ref/object.
The other reviewers have done a great job at reviewing this module. I just wanted to say how helpful this module is.
Remember the name of this module it _will_ come handy someday.
I love this thing! It lets me dig out the context of those mysterious warnings from deep down in the module without having to pull out the debugger or edit code.
I love this and use it lots. Being able to decide whether I want stack traces on exceptions on a per-script-invocation basis is much more useful than having to decide whether to produce a stack trace on a per-exception-site basis. Itâ€™s excellent for printf debugging people like me: instead of having to meddle with the code, just rerun it under Carp::Always and you get a stack trace. For many simple bugs, this already provides enough information to find and fix them.
Four thumbs up!
PS.: Please disregard Robert Rothenbergâ€™s review; he does not appear to have understood the docs. The difference between loading Carp with the `verbose` import option and Carp::Always is that Carp::Always will generate stack traces from plain `die`s and `warn`s, whereas the `verbose` import option to Carp only enables them for `croak`s and `carp`s. The fact that Carp does not need to change die/warn handlers is therefore not an advantage, but a missing feature â€“ nor is it usually relevant, because Carp::Always is intended for loading from outside the script (via PERL5LIB or perlâ€™s -M switch), not as part of the regular operation of code. (It does mean that sometimes Carp::Always wonâ€™t work as advertised, but with the means provided by Perl, this cannot be helped.)
This module hasn't really explained why it is better than carp: it traps the DIE and WARN handlers so that the carp "longmess" stack traces are always used. That should be made clearer. Which is nice, but...
The docs state that the current version doesn't play well with other modules that change the die/warn handlers. This is something that can be fixed easily. (It's done in Win32::EventLog::Carp -- which I wrote -- for instance.)
I'm not sure that I like warnings to always be verbose, though.
Modules like this deserve to be more well-known and should perhaps included in core Perl (or even become a command-line switch). I'm never comfortable with Carp and all the "complexity" of using it. What I wanted is simple, when debugging I want all die()'s (and perhaps warn() too, but much less often) to print a stack trace.
Call me inflicted with Ruby- or Python-envy, but it's been so ridiculous wanting to print out stack traces in Perl. I don't want to have to change/rewrite all my die()'s to croak() or confess()! And what about library codes which use die()?
Thank God somebody wrote Carp::Always.
A brilliant module, handling a common debugging trick with perfect simplicity. I'd almost like to see this incorporated into Carp in the core.