Skip to content

Commit

Permalink
Include original error message in the text version of StackTrace
Browse files Browse the repository at this point in the history
Also passes indent => 1 so we don't need the janky trace_as_string().
Note that this code does not seem to work with Devel::StackTrace::WithLexicals
as of this writing because it ignores 'message' and 'indent' :(

Going to patch it.
  • Loading branch information
miyagawa committed Dec 3, 2010
1 parent 88b3c60 commit e787a47
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions lib/Plack/Middleware/StackTrace.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ sub call {

my $trace;
local $SIG{__DIE__} = sub {
$trace = $StackTraceClass->new;
$trace = $StackTraceClass->new(indent => 1, message => $_[0]);
die @_;
};

my $caught;
my $res = try { $self->app->($env) } catch { $caught = $_ };

if ($trace && ($caught || ($self->force && ref $res eq 'ARRAY' && $res->[0] == 500)) ) {
my $text = trace_as_string($trace);
my $text = $trace->as_string;
my $html = $trace->as_html;
$env->{'plack.stacktrace.text'} = $text;
$env->{'plack.stacktrace.html'} = $html;
Expand All @@ -47,21 +47,6 @@ sub call {
return $res;
}

sub trace_as_string {
my $trace = shift;

my $st = '';
my $first = 1;
foreach my $f ( $trace->frames() ) {
$st .= "\t" unless $first;
$st .= $f->as_string($first) . "\n";
$first = 0;
}

return $st;

}

sub utf8_safe {
my $str = shift;

Expand Down

0 comments on commit e787a47

Please sign in to comment.