File Coverage

blib/lib/autodie/exception/system.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition 1 3 33.3
subroutine 7 7 100.0
pod 1 1 100.0
total 29 31 93.5


line stmt bran cond sub pod time code
1             package autodie::exception::system;
2 2     2   55 use 5.008;
  2         10  
  2         81  
3 2     2   11 use strict;
  2         3  
  2         83  
4 2     2   10 use warnings;
  2         11  
  2         81  
5 2     2   11 use parent 'autodie::exception';
  2         3  
  2         13  
6 2     2   110 use Carp qw(croak);
  2         3  
  2         308  
7              
8             our $VERSION = '2.28'; # VERSION: Generated by DZP::OurPkg:Version
9              
10             # ABSTRACT: Exceptions from autodying system().
11              
12             my $PACKAGE = __PACKAGE__;
13              
14             =head1 NAME
15              
16             autodie::exception::system - Exceptions from autodying system().
17              
18             =head1 SYNOPSIS
19              
20             eval {
21             use autodie qw(system);
22              
23             system($cmd, @args);
24              
25             };
26              
27             if (my $E = $@) {
28             say "Ooops! ",$E->caller," had problems: $@";
29             }
30              
31              
32             =head1 DESCRIPTION
33              
34             This is a L<autodie::exception> class for failures from the
35             C<system> command.
36              
37             Presently there is no way to interrogate an C<autodie::exception::system>
38             object for the command, exit status, and other information you'd expect
39             such an object to hold. The interface will be expanded to accommodate
40             this in the future.
41              
42             =cut
43              
44             sub _init {
45 2     2   22 my ($this, %args) = @_;
46              
47 2   33     149 $this->{$PACKAGE}{message} = $args{message}
48             || croak "'message' arg not supplied to autodie::exception::system->new";
49              
50 2         27 return $this->SUPER::_init(%args);
51              
52             }
53              
54             =head2 stringify
55              
56             When stringified, C<autodie::exception::system> objects currently
57             use the message generated by L<IPC::System::Simple>.
58              
59             =cut
60              
61             sub stringify {
62              
63 5     5 1 1467 my ($this) = @_;
64              
65 5         34 return $this->{$PACKAGE}{message} . $this->add_file_and_line;
66              
67             }
68              
69             1;
70              
71             __END__
72              
73             =head1 LICENSE
74              
75             Copyright (C)2008 Paul Fenwick
76              
77             This is free software. You may modify and/or redistribute this
78             code under the same terms as Perl 5.10 itself, or, at your option,
79             any later version of Perl 5.
80              
81             =head1 AUTHOR
82              
83             Paul Fenwick E<lt>pjf@perltraining.com.auE<gt>