Skip to content

Commit

Permalink
mention trace behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 26, 2016
1 parent 85b0fbd commit 1c2396d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Mojo/Exception.pm
Expand Up @@ -205,11 +205,15 @@ Render exception.
$e = $e->trace;
$e = $e->trace($skip);
Generate stack trace and store all L</"frames">.
Generate stack trace and store all L</"frames">, defaults to skipping C<1> call
frame.
# Skip 3 call frames in stack trace
# Skip 3 call frames
$e->trace(3);
# Skip no call frames
$e->trace(0);
=head1 OPERATORS
L<Mojo::Exception> overloads the following operators.
Expand Down
8 changes: 8 additions & 0 deletions t/mojo/exception.t
Expand Up @@ -50,4 +50,12 @@ is $e->lines_after->[3][1], '};', 'right line';
is $e->lines_after->[4][0], 25, 'right number';
is $e->lines_after->[4][1], '$e = $@;', 'right line';

# Trace
sub wrapper2 { Mojo::Exception->new->trace(@_) }
sub wrapper1 { wrapper2(@_) }
like wrapper1()->frames->[0][3], qr/wrapper2/, 'right subroutine';
like wrapper1(0)->frames->[0][3], qr/trace/, 'right subroutine';
like wrapper1(1)->frames->[0][3], qr/wrapper2/, 'right subroutine';
like wrapper1(2)->frames->[0][3], qr/wrapper1/, 'right subroutine';

done_testing();

0 comments on commit 1c2396d

Please sign in to comment.