File Coverage

blib/lib/Enbld/Error.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 0 3 0.0
total 23 26 88.4


line stmt bran cond sub pod time code
1             package Enbld::Error;
2              
3 12     12   830 use strict;
  12         18  
  12         522  
4 12     12   48 use warnings;
  12         13  
  12         379  
5              
6             use overload (
7 12         88 q{""} => 'to_string',
8             fallback => 1,
9 12     12   59 );
  12         17  
10              
11             sub throw {
12 9     9 0 34 my ( $class, $message ) = @_;
13              
14 9         49 die $class->new( $message );
15             }
16              
17             sub new {
18 14     14 0 1207 my ( $class, $message ) = @_;
19              
20 14         44 chomp( $message );
21              
22 14         51 my $self = {
23             message => $message,
24             };
25              
26 14         228 return bless $self, $class;
27             }
28              
29             sub to_string {
30 13     13 0 913 my $self = shift;
31              
32 13         107 return "ERROR:$self->{message}\n";
33             }
34              
35             1;