| 1 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | package IPC::Open3::Callback::CommandFailedException; | ||||||||||
| 5 | 1 | $IPC::Open3::Callback::CommandFailedException::VERSION = '1.19'; | |||||||||
| 6 | # ABSTRACT: An exception thrown when run_or_die encounters a failed command | ||||||||||
| 7 | # PODNAME: IPC::Open3::Callback::CommandFailedException | ||||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use overload q{""} => 'to_string', fallback => 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use parent qw(Class::Accessor); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | __PACKAGE__->follow_best_practice; | |||||||||
| 12 | 1 | __PACKAGE__->mk_ro_accessors(qw(command exit_status out err)); | |||||||||
| 13 | |||||||||||
| 14 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 15 | 0 | my ( $class, @args ) = @_; | |||||||||
| 16 | 0 | return bless( {}, $class )->_init(@args); | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 0 | ▶ | sub _init { | ||||||||
|
Subroutine
_init: not called CC=3 SCAR=24.8
| |||||||||||
| 20 | 0 | my ( $self, $command, $exit_status, $out, $err ) = @_; | |||||||||
| 21 | |||||||||||
| 22 | 0 | $self->{command} = $command; | |||||||||
| 23 | 0 | $self->{exit_status} = $exit_status; | |||||||||
| 24 | 0 | ▶ | if ( defined($out) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 0 | $out =~ s/^\s+//; | |||||||||
| 26 | 0 | $out =~ s/\s+$//; | |||||||||
| 27 | 0 | $self->{out} = $out; | |||||||||
| 28 | } | ||||||||||
| 29 | 0 | ▶ | if ( defined($err) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 0 | $err =~ s/^\s+//; | |||||||||
| 31 | 0 | $err =~ s/\s+$//; | |||||||||
| 32 | 0 | $self->{err} = $err; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 0 | return $self; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub to_string { | ||||||||
|
Subroutine
to_string: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 39 | 0 | my ($self) = @_; | |||||||||
| 40 | 0 | ▶ | if ( !$self->{message} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | my @message = ( 'FAILED (', $self->{exit_status}, '): ', @{ $self->{command} } ); | |||||||||
| 42 | 0 | ▶ | if ( $self->{out} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 0 | push( @message, "\n***** out *****\n", $self->{out}, "\n***** end out *****" ); | |||||||||
| 44 | } | ||||||||||
| 45 | 0 | ▶ | if ( $self->{err} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 0 | push( @message, "\n***** err *****\n", $self->{err}, "\n***** end err *****" ); | |||||||||
| 47 | } | ||||||||||
| 48 | 0 | $self->{message} = join( '', @message ); | |||||||||
| 49 | } | ||||||||||
| 50 | 0 | return $self->{message}; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 1 | 1; | |||||||||
| 54 | |||||||||||
| 55 | __END__ | ||||||||||