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