line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
12
|
|
|
12
|
|
69
|
use strict; |
|
12
|
|
|
|
|
27
|
|
|
12
|
|
|
|
|
294
|
|
2
|
12
|
|
|
12
|
|
58
|
use warnings; |
|
12
|
|
|
|
|
24
|
|
|
12
|
|
|
|
|
476
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Footprintless::CommandRunner::ExecutionException; |
5
|
|
|
|
|
|
|
$Footprintless::CommandRunner::ExecutionException::VERSION = '1.26'; |
6
|
|
|
|
|
|
|
# ABSTRACT: An exception for failures when executing commands |
7
|
|
|
|
|
|
|
# PODNAME: Footprintless::CommandRunner::ExecutionException |
8
|
|
|
|
|
|
|
|
9
|
12
|
|
|
12
|
|
4287
|
use Term::ANSIColor; |
|
12
|
|
|
|
|
80074
|
|
|
12
|
|
|
|
|
929
|
|
10
|
12
|
|
|
12
|
|
104
|
use overload '""' => 'to_string'; |
|
12
|
|
|
|
|
26
|
|
|
12
|
|
|
|
|
102
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
6
|
|
|
6
|
1
|
74
|
return bless( {}, shift )->_init(@_); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _init { |
17
|
6
|
|
|
6
|
|
72
|
my ( $self, $command, $exit_code, $message, $stderr ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
|
|
|
238
|
$self->{command} = $command; |
20
|
6
|
|
|
|
|
138
|
$self->{exit_code} = $exit_code; |
21
|
6
|
|
|
|
|
44
|
$self->{message} = $message; |
22
|
6
|
|
|
|
|
36
|
$self->{stderr} = $stderr; |
23
|
6
|
|
|
|
|
44
|
$self->{trace} = []; |
24
|
|
|
|
|
|
|
|
25
|
6
|
|
|
|
|
76
|
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
|
26
|
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
|
117
|
my ($self) = @_; |
67
|
|
|
|
|
|
|
|
68
|
8
|
|
|
|
|
32
|
my @parts = ( $self->{exit_code} ); |
69
|
8
|
100
|
|
|
|
48
|
push( @parts, ": $self->{message}" ) if ( $self->{message} ); |
70
|
|
|
|
|
|
|
push( @parts, "\n****STDERR****\n$self->{stderr}\n****STDERR****" ) |
71
|
8
|
50
|
|
|
|
49
|
if ( $self->{stderr} ); |
72
|
8
|
|
|
|
|
47
|
push( @parts, "\n", $self->_trace_string() ); |
73
|
|
|
|
|
|
|
|
74
|
8
|
|
|
|
|
77
|
return join( '', @parts ); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _trace_string { |
78
|
8
|
|
|
8
|
|
172
|
my ($self) = @_; |
79
|
8
|
|
|
|
|
34
|
my @parts = (); |
80
|
8
|
50
|
|
|
|
20
|
if ( @{ $self->{trace} } ) { |
|
8
|
|
|
|
|
46
|
|
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__ |