line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
12
|
|
|
12
|
|
64
|
use strict; |
|
12
|
|
|
|
|
18
|
|
|
12
|
|
|
|
|
301
|
|
2
|
12
|
|
|
12
|
|
48
|
use warnings; |
|
12
|
|
|
|
|
18
|
|
|
12
|
|
|
|
|
507
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Footprintless::CommandRunner::ExecutionException; |
5
|
|
|
|
|
|
|
$Footprintless::CommandRunner::ExecutionException::VERSION = '1.28'; |
6
|
|
|
|
|
|
|
# ABSTRACT: An exception for failures when executing commands |
7
|
|
|
|
|
|
|
# PODNAME: Footprintless::CommandRunner::ExecutionException |
8
|
|
|
|
|
|
|
|
9
|
12
|
|
|
12
|
|
5936
|
use Term::ANSIColor; |
|
12
|
|
|
|
|
80036
|
|
|
12
|
|
|
|
|
777
|
|
10
|
12
|
|
|
12
|
|
88
|
use overload '""' => 'to_string'; |
|
12
|
|
|
|
|
21
|
|
|
12
|
|
|
|
|
76
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
6
|
|
|
6
|
1
|
108
|
return bless( {}, shift )->_init(@_); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _init { |
17
|
6
|
|
|
6
|
|
69
|
my ( $self, $command, $exit_code, $message, $stderr ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
|
|
|
218
|
$self->{command} = $command; |
20
|
6
|
|
|
|
|
70
|
$self->{exit_code} = $exit_code; |
21
|
6
|
|
|
|
|
54
|
$self->{message} = $message; |
22
|
6
|
|
|
|
|
41
|
$self->{stderr} = $stderr; |
23
|
6
|
|
|
|
|
72
|
$self->{trace} = []; |
24
|
|
|
|
|
|
|
|
25
|
6
|
|
|
|
|
88
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub exit { |
29
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $verbose ) = @_; |
30
|
0
|
0
|
|
|
|
0
|
print( STDERR "$self->{message}\n" ) if ( $self->{message} ); |
31
|
0
|
0
|
|
|
|
0
|
print( STDERR "$self->{stderr}\n" ) if ( $self->{stderr} ); |
32
|
0
|
0
|
|
|
|
0
|
if ($verbose) { |
33
|
0
|
|
|
|
|
0
|
print( STDERR colored( ['red'], "[$self->{command}]" ), |
34
|
|
|
|
|
|
|
" failed ($self->{exit_code})\n" ); |
35
|
0
|
|
|
|
|
0
|
print( STDERR $self->_trace_string(), "\n" ); |
36
|
|
|
|
|
|
|
} |
37
|
0
|
|
|
|
|
0
|
exit $self->{exit_code}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_command { |
41
|
0
|
|
|
0
|
1
|
0
|
return $_[0]->{command}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub get_exit_code { |
45
|
2
|
|
|
2
|
1
|
51
|
return $_[0]->{exit_code}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub get_message { |
49
|
0
|
|
|
0
|
1
|
0
|
return $_[0]->{message}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub get_stderr { |
53
|
0
|
|
|
0
|
1
|
0
|
return $_[0]->{stderr}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub get_trace { |
57
|
0
|
|
|
0
|
1
|
0
|
return $_[0]->{trace}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub PROPAGATE { |
61
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $file, $line ) = @_; |
62
|
0
|
|
|
|
|
0
|
push( @{ $self->{trace} }, [ $file, $line ] ); |
|
0
|
|
|
|
|
0
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub to_string { |
66
|
8
|
|
|
8
|
1
|
151
|
my ($self) = @_; |
67
|
|
|
|
|
|
|
|
68
|
8
|
|
|
|
|
47
|
my @parts = ( $self->{exit_code} ); |
69
|
8
|
100
|
|
|
|
49
|
push( @parts, ": $self->{message}" ) if ( $self->{message} ); |
70
|
|
|
|
|
|
|
push( @parts, "\n****STDERR****\n$self->{stderr}\n****STDERR****" ) |
71
|
8
|
50
|
|
|
|
34
|
if ( $self->{stderr} ); |
72
|
8
|
|
|
|
|
56
|
push( @parts, "\n", $self->_trace_string() ); |
73
|
|
|
|
|
|
|
|
74
|
8
|
|
|
|
|
88
|
return join( '', @parts ); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _trace_string { |
78
|
8
|
|
|
8
|
|
27
|
my ($self) = @_; |
79
|
8
|
|
|
|
|
30
|
my @parts = (); |
80
|
8
|
50
|
|
|
|
25
|
if ( @{ $self->{trace} } ) { |
|
8
|
|
|
|
|
36
|
|
81
|
0
|
|
|
|
|
0
|
push( @parts, "****TRACE****" ); |
82
|
0
|
|
|
|
|
0
|
foreach my $stop ( @{ $self->{trace} } ) { |
|
0
|
|
|
|
|
0
|
|
83
|
0
|
|
|
|
|
0
|
push( @parts, "$stop->[0]($stop->[1])" ); |
84
|
|
|
|
|
|
|
} |
85
|
0
|
|
|
|
|
0
|
push( @parts, "\n****TRACE****" ); |
86
|
|
|
|
|
|
|
} |
87
|
8
|
|
|
|
|
58
|
return join( '', @parts ); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |