/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 470 - (hide annotations)
Thu Nov 20 10:55:46 2008 UTC (15 years, 6 months ago) by dpavlin
File size: 962 byte(s)
make caller_fields lazy
1 dpavlin 465 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 dpavlin 470 lazy => 1,
17 dpavlin 465 default => sub { [ qw/
18     package filename line
19     subroutine hasargs
20     wantarray evaltext is_require
21     hints bitmask hinthash
22     / ] },
23     );
24    
25     =head2 backtrace
26    
27     my @backtrace = $self->backtrace;
28    
29     =cut
30    
31     sub backtrace {
32     my ($self) = @_;
33    
34     my @backtrace;
35     foreach ( 0 .. 5 ) {
36     my @caller = caller($_) or last;
37     push @backtrace, join(' ',
38     map {
39     my $name = $self->caller_fields->[$_];
40     my $val = $caller[$_];
41     if ( $name eq 'filename' ) {
42     my $line = $caller[ $_ + 1 ];
43     qq|$name <a target="editor" href="/editor+$val+$line">$val</a>|;
44     } else {
45     $name . ': ' . dump $val
46     }
47     } ( 0 .. $#{ $self->caller_fields } )
48     );
49     }
50     warn "# backtrace: ", dump( @backtrace ) if @backtrace;
51     return @backtrace;
52     }
53    
54     1;

  ViewVC Help
Powered by ViewVC 1.1.26