xref: /openbsd-src/gnu/usr.bin/perl/cpan/autodie/lib/autodie/exception/system.pm (revision 3d61058aa5c692477b6d18acfbbdb653a9930ff9)
1package autodie::exception::system;
2use 5.008;
3use strict;
4use warnings;
5use parent 'autodie::exception';
6use Carp qw(croak);
7
8our $VERSION = '2.37'; # VERSION: Generated by DZP::OurPkg:Version
9
10# ABSTRACT: Exceptions from autodying system().
11
12my $PACKAGE = __PACKAGE__;
13
14=head1 NAME
15
16autodie::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
34This is a L<autodie::exception> class for failures from the
35C<system> command.
36
37Presently there is no way to interrogate an C<autodie::exception::system>
38object for the command, exit status, and other information you'd expect
39such an object to hold.  The interface will be expanded to accommodate
40this in the future.
41
42=cut
43
44sub _init {
45    my ($this, %args) = @_;
46
47    $this->{$PACKAGE}{message} = $args{message}
48        || croak "'message' arg not supplied to autodie::exception::system->new";
49
50    return $this->SUPER::_init(%args);
51
52}
53
54=head2 stringify
55
56When stringified, C<autodie::exception::system> objects currently
57use the message generated by L<IPC::System::Simple>.
58
59=cut
60
61sub stringify {
62
63    my ($this) = @_;
64
65    return $this->{$PACKAGE}{message} . $this->add_file_and_line;
66
67}
68
691;
70
71__END__
72
73=head1 LICENSE
74
75Copyright (C)2008 Paul Fenwick
76
77This is free software.  You may modify and/or redistribute this
78code under the same terms as Perl 5.10 itself, or, at your option,
79any later version of Perl 5.
80
81=head1 AUTHOR
82
83Paul Fenwick E<lt>pjf@perltraining.com.auE<gt>
84