File Coverage

blib/lib/MooX/Ipc/Cmd/Exception.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             #ABSTRACT: Exception class for MooX::Ipc::Cmd role
2             package MooX::Ipc::Cmd::Exception;
3 5     5   896 use Moo;
  5         3072  
  5         44  
4             our $VERSION = '1.2.0'; #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 5         40 q{""} => 'as_string',
13 5     5   4112 fallback => 1;
  5         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__