line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#ABSTRACT: Exception class for MooX::Ipc::Cmd role |
2
|
|
|
|
|
|
|
package MooX::Ipc::Cmd::Exception; |
3
|
4
|
|
|
4
|
|
23
|
use Moo; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
44
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.1.2'; #VERSION |
5
|
|
|
|
|
|
|
extends 'Throwable::Error'; |
6
|
|
|
|
|
|
|
has 'stderr' => (is => 'ro', predicate => 1,); |
7
|
|
|
|
|
|
|
has 'cmd' => (is => 'ro', required => 1,); |
8
|
|
|
|
|
|
|
has 'exit_status' => (is => 'ro', required => 1); |
9
|
|
|
|
|
|
|
has 'signal' => (is => 'ro', predicate => 1,); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use overload |
12
|
4
|
|
|
|
|
37
|
q{""} => 'as_string', |
13
|
4
|
|
|
4
|
|
1781
|
fallback => 1; |
|
4
|
|
|
|
|
10
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has +stack_trace_args => ( |
16
|
|
|
|
|
|
|
is=>'ro', |
17
|
|
|
|
|
|
|
default=>sub{return [ skip_frames=>5,ignore_package=>['MooX::Ipc::Cmd','MooX::Ipc::Cmd::Exception'] ]}, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
#message to print when dieing |
20
|
|
|
|
|
|
|
has +message => ( |
21
|
|
|
|
|
|
|
is =>'ro', |
22
|
|
|
|
|
|
|
lazy => 1, |
23
|
|
|
|
|
|
|
default => sub { |
24
|
|
|
|
|
|
|
my $self = shift; |
25
|
|
|
|
|
|
|
my $str = join(" ", @{$self->cmd}); |
26
|
|
|
|
|
|
|
if ($self->has_signal) |
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
$str .= " failed with signal " . $self->signal; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else |
31
|
|
|
|
|
|
|
{ |
32
|
|
|
|
|
|
|
$str .= " failed with exit status " . $self->exit_status; |
33
|
|
|
|
|
|
|
if ($self->has_stderr && defined $self->stderr) |
34
|
|
|
|
|
|
|
{ |
35
|
|
|
|
|
|
|
$str .= "\nSTDERR is :\n " . join("\n ", @{$self->stderr}); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
return $str; |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |