line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
12
|
|
|
12
|
|
69
|
use strict; |
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
297
|
|
2
|
12
|
|
|
12
|
|
52
|
use warnings; |
|
12
|
|
|
|
|
22
|
|
|
12
|
|
|
|
|
1248
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Footprintless::CommandRunner::ExecutionException; |
5
|
|
|
|
|
|
|
$Footprintless::CommandRunner::ExecutionException::VERSION = '1.29'; |
6
|
|
|
|
|
|
|
# ABSTRACT: An exception for failures when executing commands |
7
|
|
|
|
|
|
|
# PODNAME: Footprintless::CommandRunner::ExecutionException |
8
|
|
|
|
|
|
|
|
9
|
12
|
|
|
12
|
|
6409
|
use Term::ANSIColor; |
|
12
|
|
|
|
|
99759
|
|
|
12
|
|
|
|
|
1567
|
|
10
|
12
|
|
|
12
|
|
93
|
use overload '""' => 'to_string'; |
|
12
|
|
|
|
|
25
|
|
|
12
|
|
|
|
|
101
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
6
|
|
|
6
|
1
|
101
|
return bless( {}, shift )->_init(@_); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _init { |
17
|
6
|
|
|
6
|
|
64
|
my ( $self, $command, $exit_code, $message, $stderr ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
|
|
|
239
|
$self->{command} = $command; |
20
|
6
|
|
|
|
|
39
|
$self->{exit_code} = $exit_code; |
21
|
6
|
|
|
|
|
61
|
$self->{message} = $message; |
22
|
6
|
|
|
|
|
42
|
$self->{stderr} = $stderr; |
23
|
6
|
|
|
|
|
57
|
$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
|
141
|
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
|
164
|
my ($self) = @_; |
67
|
|
|
|
|
|
|
|
68
|
8
|
|
|
|
|
36
|
my @parts = ( $self->{exit_code} ); |
69
|
8
|
100
|
|
|
|
51
|
push( @parts, ": $self->{message}" ) if ( $self->{message} ); |
70
|
|
|
|
|
|
|
push( @parts, "\n****STDERR****\n$self->{stderr}\n****STDERR****" ) |
71
|
8
|
50
|
|
|
|
47
|
if ( $self->{stderr} ); |
72
|
8
|
|
|
|
|
57
|
push( @parts, "\n", $self->_trace_string() ); |
73
|
|
|
|
|
|
|
|
74
|
8
|
|
|
|
|
92
|
return join( '', @parts ); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _trace_string { |
78
|
8
|
|
|
8
|
|
28
|
my ($self) = @_; |
79
|
8
|
|
|
|
|
23
|
my @parts = (); |
80
|
8
|
50
|
|
|
|
23
|
if ( @{ $self->{trace} } ) { |
|
8
|
|
|
|
|
44
|
|
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
|
|
|
|
|
45
|
return join( '', @parts ); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |