File Coverage

lib/Text/Tradition/Error.pm
Criterion Covered Total %
statement 18 20 90.0
branch n/a
condition n/a
subroutine 6 7 85.7
pod n/a
total 24 27 88.8


line stmt bran cond sub pod time code
1             package Text::Tradition::Error;
2              
3 10     10   76 use strict;
  10         28  
  10         339  
4 10     10   64 use warnings;
  10         24  
  10         318  
5 10     10   83 use Moose;
  10         25  
  10         66  
6 10     10   74053 use overload '""' => \&_stringify, 'fallback' => 1;
  10         28  
  10         109  
7              
8             with qw/ Throwable::X StackTrace::Auto /;
9 10     10   5256 use Throwable::X -all;
  10         3127116  
  10         74  
10              
11             around 'throw' => sub {
12             my $orig = shift;
13             my $self = shift;
14             my %args = @_;
15             my $msg = exists $args{message} ? $args{message} : undef;
16             if( $msg && UNIVERSAL::can( $msg, 'message' ) ) {
17             $args{message} = $msg->message;
18             }
19             $self->$orig( %args );
20             };
21              
22             sub _stringify {
23 0     0     my $self = shift;
24 0           return "Error: " . $self->ident . " // " . $self->message
25             . "\n" . $self->stack_trace->as_string;
26             }
27              
28 10     10   5870 no Moose;
  10         27  
  10         83  
29             __PACKAGE__->meta->make_immutable( inline_constructor => 0 );
30              
31             =head1 NAME
32              
33             Text::Tradition::Error - throwable error class for Tradition package
34              
35             =head1 DESCRIPTION
36              
37             A basic exception class to throw around, as it were.
38              
39             =head1 LICENSE
40              
41             This package is free software and is provided "as is" without express
42             or implied warranty. You can redistribute it and/or modify it under
43             the same terms as Perl itself.
44              
45             =head1 AUTHOR
46              
47             Tara L Andrews E<lt>aurum@cpan.orgE<gt>