/[Frey]/trunk/lib/Frey/Backtrace.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Frey/Backtrace.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 465 - (show annotations)
Wed Nov 19 19:11:52 2008 UTC (15 years, 5 months ago) by dpavlin
File size: 950 byte(s)
split backtrace generation into Frey::Backtrace
1 package Frey::Backtrace;
2 use Moose::Role;
3
4 use Data::Dump qw/dump/;
5
6 =head1 DESCRIPTION
7
8 Show backtrace with links to editor
9
10 =cut
11
12 has 'caller_fields' => (
13 is => 'rw',
14 isa => 'ArrayRef[Str]',
15 required => 1,
16 default => sub { [ qw/
17 package filename line
18 subroutine hasargs
19 wantarray evaltext is_require
20 hints bitmask hinthash
21 / ] },
22 );
23
24 =head2 backtrace
25
26 my @backtrace = $self->backtrace;
27
28 =cut
29
30 sub backtrace {
31 my ($self) = @_;
32
33 my @backtrace;
34 foreach ( 0 .. 5 ) {
35 my @caller = caller($_) or last;
36 push @backtrace, join(' ',
37 map {
38 my $name = $self->caller_fields->[$_];
39 my $val = $caller[$_];
40 if ( $name eq 'filename' ) {
41 my $line = $caller[ $_ + 1 ];
42 qq|$name <a target="editor" href="/editor+$val+$line">$val</a>|;
43 } else {
44 $name . ': ' . dump $val
45 }
46 } ( 0 .. $#{ $self->caller_fields } )
47 );
48 }
49 warn "# backtrace: ", dump( @backtrace ) if @backtrace;
50 return @backtrace;
51 }
52
53 1;

  ViewVC Help
Powered by ViewVC 1.1.26