File Coverage

blib/lib/XAS/Exception.pm
Criterion Covered Total %
statement 6 17 35.2
branch 0 6 0.0
condition 0 3 0.0
subroutine 2 5 40.0
pod 3 3 100.0
total 11 34 32.3


line stmt bran cond sub pod time code
1             package XAS::Exception;
2              
3 1     1   4 use base Badger::Exception;
  1         1  
  1         166  
4             $Badger::Exception::TRACE = 1;
5              
6             sub type {
7 0     0 1   my $self = shift;
8              
9             return @_
10             ? ($self->{'type'} = shift)
11 0 0 0       : ($self->{'type'} || $TYPE);
12            
13             }
14              
15             sub type_info {
16 0     0 1   my $self = shift;
17              
18 0           return $self->type, $self->info;
19              
20             }
21              
22             sub stack_trace {
23 0     0 1   my $self = shift;
24              
25 0           my @lines;
26              
27 0 0         if (my $stack = $self->{ stack }) {
28              
29 0           foreach my $caller (@$stack) {
30              
31             # ignore Try::Tiny lines
32              
33 1     1   3 no warnings;
  1         1  
  1         93  
34              
35 0 0         next if (grep( $_ =~ /Try::Tiny/, @$caller ));
36 0           push(@lines, $self->message( caller => @$caller ));
37              
38             }
39              
40             }
41              
42 0           return join("\n", @lines);
43              
44             }
45              
46             1;
47              
48             __END__
49              
50             =head1 NAME
51              
52             XAS::Exception - The base exception class for the XAS environment
53              
54             =head1 DESCRIPTION
55              
56             This module defines a base exception class for the XAS Environment and
57             inherits from L<Badger::Exception|https://metacpan.org/Badger::Exception>.
58             The only differences is that it turns stack tracing on by default.
59              
60             =head1 METHODS
61              
62             =head2 type
63              
64             This provides the missing type() method from L<Badger::Exception|https://metacpan.org/pod/Badger::Exception>.
65              
66             =head2 type_info
67              
68             This provides the missing type_info() method from L<Badger::Exception|https://metacpan.org/pod/Badger::Exception>.
69              
70             =head2 stack_trace
71              
72             Removes any reference to L<Try::Tiny|https://metacpan.org/pod/Try::Tiny> in the stack trace.
73              
74             =head1 SEE ALSO
75              
76             =over 4
77              
78             =item L<XAS|XAS>
79              
80             =back
81              
82             =head1 AUTHOR
83              
84             Kevin L. Esteb, E<lt>kevin@kesteb.usE<gt>
85              
86             =head1 COPYRIGHT AND LICENSE
87              
88             Copyright (C) 2014 Kevin L. Esteb
89              
90             This is free software; you can redistribute it and/or modify it under
91             the terms of the Artistic License 2.0. For details, see the full text
92             of the license at http://www.perlfoundation.org/artistic_license_2_0.
93              
94             =cut