File Coverage

blib/lib/MooX/Ipc/Cmd/Exception.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 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   566 use Moo;
  5         1861  
  5         55  
4             our $VERSION = '1.2.1'; #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 5     5   5769 use namespace::autoclean;
  5         48826  
  5         20  
11             use overload
12 5         38 q{""} => 'as_string',
13 5     5   366 fallback => 1;
  5         12  
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__