Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Greetings, monks.
I'm doing some database transactions along with some other code, and sometimes things fail. I'd like to get a proper backtrace for them:
use Carp; sub sub1 { sub3(); sub2(); } # want the backtrace down to sub2 or sub3 sub sub2 { die "code failure"; } sub sub3 { die "runtime error" if rand() < 0.25 } sub main_sub { eval { #$dbh->begin_work; # various things, not all db-related sub1(); # more things #$dbh->commit; }; if ($@) { #$dbh->rollback; print STDERR $@; confess "the transaction failed"; }; } main_sub();
All I am getting is the backtrace to main_sub, and the line number of the die. How do I get a non-truncated backtrace?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to print the backtrace in a "catch" block?
by Corion (Patriarch) on Jan 16, 2012 at 15:37 UTC | |
by tobyink (Canon) on Jan 16, 2012 at 16:41 UTC | |
by Anonymous Monk on Jan 16, 2012 at 17:07 UTC | |
by Anonymous Monk on Jan 16, 2012 at 15:48 UTC | |
by Corion (Patriarch) on Jan 16, 2012 at 16:18 UTC | |
by Anonymous Monk on Jan 16, 2012 at 17:15 UTC | |
by tobyink (Canon) on Jan 16, 2012 at 17:25 UTC | |
by Marshall (Canon) on Jan 16, 2012 at 17:20 UTC | |
by Anonymous Monk on Jan 16, 2012 at 16:31 UTC |