File Coverage

blib/lib/Enbld/Exception.pm
Criterion Covered Total %
statement 24 24 100.0
branch 3 4 75.0
condition n/a
subroutine 7 7 100.0
pod 0 2 0.0
total 34 37 91.8


line stmt bran cond sub pod time code
1             package Enbld::Exception;
2              
3 25     25   600 use strict;
  25         29  
  25         588  
4 25     25   74 use warnings;
  25         27  
  25         481  
5              
6 25     25   69 use Carp;
  25         26  
  25         1067  
7 25     25   12750 use Data::Dumper;
  25         114736  
  25         1707  
8              
9             use overload (
10 25         166 q{""} => \&to_string,
11             fallback => 1,
12 25     25   162 );
  25         26  
13              
14             sub new {
15 79     79 0 661 my ( $class, $message, $param ) = @_;
16              
17 79         126 chomp( $message );
18              
19 79 100       153 if ( $param ) { $message .= "\n" . Dumper( $param ) };
  40         100  
20              
21 79 50       3227 my $location = $ENV{HARNESS_ACTIVE} ? Carp::longmess() : Carp::shortmess();
22              
23 79         35064 my $self = {
24             message => $message,
25             caller_location => $location,
26             };
27              
28 79         597 return bless $self, $class;
29             }
30              
31             sub to_string {
32 79     79 0 3971 my $self = shift;
33              
34 79         489 return "ABORT:$self->{message}$self->{caller_location}";
35             }
36              
37             1;