Footprintless/App/UsageException.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 59 CC 2 SCAR 10.0
CC
2
Cov
0%
to_string
6.0
new
2.0
_init
2.0
CRAP 2.7
1 use strict;
2 use warnings;
3  
4 package Footprintless::App::UsageException;
5 $Footprintless::App::UsageException::VERSION = '1.29';
6 # ABSTRACT: An exception that indicates the invalid usage of a command
7 # PODNAME: Footprintless::App::UsageException
8  
9 use Term::ANSIColor;
10 use overload '""' => 'to_string';
11  
12 sub new {
13 return bless( {}, shift )->_init(@_);
14 }
15  
16 sub _init {
17 my ( $self, $message, $coordinate ) = @_;
18  
19 $self->{message} = $message;
20 $self->{trace} = [];
21  
22 return $self;
23 }
24  
25 sub get_message {
26 return $_[0]->{message};
27 }
28  
29 sub get_trace {
30 return $_[0]->{trace};
31 }
32  
33 sub PROPAGATE {
34 my ( $self, $file, $line ) = @_;
35 push( @{ $self->{trace} }, [ $file, $line ] );
36 }
37  
38 sub to_string {
39 my ( $self, $trace ) = @_;
40  
41 my @parts = ( $self->{message} );
42 if ( $trace && @{ $self->{trace} } ) {
43 push( @parts, "\n****TRACE****" );
44 foreach my $stop ( @{ $self->{trace} } ) {
45 push( @parts, "$stop->[0]($stop->[1])" );
46 }
47 push( @parts, "\n****TRACE****" );
48 }
49  
50 return join( '', @parts );
51 }
52  
53 1;
54  
55 __END__