3
APR::Status - Perl Interface to the APR_STATUS_IS_* macros
10
eval { $obj->mp_method() };
11
if ($@ && $ref $@ eq 'APR::Error' && APR::Status::is_EAGAIN($@)) {
12
# APR_STATUS_IS_EAGAIN(s) of apr_errno.h is satisfied
22
An interface to F<apr_errno.h> composite error codes.
24
As discussed in the C<L<APR::Error|docs::2.0::api::APR::Error>>
25
manpage, it is possible to handle APR/Apache/mod_perl exceptions in
28
eval { $obj->mp_method() };
29
if ($@ && $ref $@ eq 'APR::Error' && $@ == $some_code)
30
warn "handled exception: $@";
33
However, in cases where C<$some_code> is an L<APR::Const
34
constant|docs::2.0::api::APR::Const>, there may be more than one
35
condition satisfying the intent of this exception. For this purpose
36
the APR C library provides in F<apr_errno.h> a series of macros,
37
C<APR_STATUS_IS_*>, which are the recommended way to check for such
38
conditions. For example, the C<APR_STATUS_IS_EAGAIN> macro is defined
41
#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \
42
|| (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \
43
|| (s) == APR_OS_START_SYSERR + SOCEWOULDBLOCK \
44
|| (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION)
46
The purpose of C<APR::Status> is to provide functions corresponding
61
Check if the error is matching C<EACCES> and its variants (corresponds
62
to the C<APR_STATUS_IS_EACCES> macro).
64
$status = APR::Status::is_EACCES($error_code);
68
=item arg1: C<$error_code> (integer or C<L<APR::Error
69
object|docs::2.0::api::APR::Error>> )
71
The error code or to check, normally C<$@> blessed into C<L<APR::Error
72
object|docs::2.0::api::APR::Error>>.
74
=item ret: C<$status> ( boolean )
80
An example of using C<is_EACCES> is when reading the contents of a
81
file where access may be forbidden:
83
eval { $obj->slurp_filename(0) };
85
return Apache2::Const::FORBIDDEN
86
if ref $@ eq 'APR::Error' && APR::Status::is_EACCES($@);
90
Due to possible variants in conditions matching C<EACCES>,
91
the use of this function is recommended for checking error codes
92
against this value, rather than just using
93
C<L<APR::Const::EACCES|docs::2.0::api::APR::Const/C_APR__Const__EACCES_>>
104
Check if the error is matching C<EAGAIN> and its variants (corresponds
105
to the C<APR_STATUS_IS_EAGAIN> macro).
107
$status = APR::Status::is_EAGAIN($error_code);
111
=item arg1: C<$error_code> (integer or C<L<APR::Error
112
object|docs::2.0::api::APR::Error>> )
114
The error code or to check, normally C<$@> blessed into C<L<APR::Error
115
object|docs::2.0::api::APR::Error>>.
117
=item ret: C<$status> ( boolean )
123
For example, here is how you may want to handle socket read exceptions
129
RETRY: eval { $socket->recv(my $buffer, SIZE) };
130
if ($@ && ref($@) && APR::Status::is_EAGAIN($@)) {
139
die "eval block has failed: $@";
142
Notice that just checking against
143
C<L<APR::Const::EAGAIN|docs::2.0::api::APR::Const/C_APR__Const__EAGAIN_>>
144
may work on some Unices, but then it will certainly break on
145
win32. Thefore make sure to use this macro and not
146
C<APR::Const::EAGAIN> unless you know what you are doing.
159
Check if the error is matching C<ENOENT> and its variants (corresponds
160
to the C<APR_STATUS_IS_ENOENT> macro).
162
$status = APR::Status::is_ENOENT($error_code);
166
=item arg1: C<$error_code> (integer or C<L<APR::Error
167
object|docs::2.0::api::APR::Error>> )
169
The error code or to check, normally C<$@> blessed into C<L<APR::Error
170
object|docs::2.0::api::APR::Error>>.
172
=item ret: C<$status> ( boolean )
178
An example of using C<is_ENOENT> is when reading the contents of a
179
file which may not exist:
181
eval { $obj->slurp_filename(0) };
183
return Apache2::Const::NOT_FOUND
184
if ref $@ eq 'APR::Error' && APR::Status::is_ENOENT($@);
188
Due to possible variants in conditions matching C<ENOENT>,
189
the use of this function is recommended for checking error codes
190
against this value, rather than just using
191
C<L<APR::Const::ENOENT|docs::2.0::api::APR::Const/C_APR__Const__ENOENT_>>
204
Check if the error is matching C<EOF> and its variants (corresponds
205
to the C<APR_STATUS_IS_EOF> macro).
207
$status = APR::Status::is_EOF($error_code);
211
=item arg1: C<$error_code> (integer or C<L<APR::Error
212
object|docs::2.0::api::APR::Error>> )
214
The error code or to check, normally C<$@> blessed into C<L<APR::Error
215
object|docs::2.0::api::APR::Error>>.
217
=item ret: C<$status> ( boolean )
223
Due to possible variants in conditions matching C<EOF>,
224
the use of this function is recommended for checking error codes
225
against this value, rather than just using
226
C<L<APR::Const::EOF|docs::2.0::api::APR::Const/C_APR__Const__EOF_>>
242
=head2 C<is_ECONNABORTED>
244
Check if the error is matching C<ECONNABORTED> and its variants (corresponds
245
to the C<APR_STATUS_IS_ECONNABORTED> macro).
247
$status = APR::Status::is_ECONNABORTED($error_code);
251
=item arg1: C<$error_code> (integer or C<L<APR::Error
252
object|docs::2.0::api::APR::Error>> )
254
The error code or to check, normally C<$@> blessed into C<L<APR::Error
255
object|docs::2.0::api::APR::Error>>.
257
=item ret: C<$status> ( boolean )
263
Due to possible variants in conditions matching C<ECONNABORTED>,
264
the use of this function is recommended for checking error codes
265
against this value, rather than just using
266
C<L<APR::Const::ECONNABORTED|docs::2.0::api::APR::Const/C_APR__Const__ECONNABORTED_>> directly.
274
=head2 C<is_ECONNRESET>
276
Check if the error is matching C<ECONNRESET> and its variants
277
(corresponds to the C<APR_STATUS_IS_ECONNRESET> macro).
279
$status = APR::Status::is_ECONNRESET($error_code);
283
=item arg1: C<$error_code> (integer or C<L<APR::Error
284
object|docs::2.0::api::APR::Error>> )
286
The error code or to check, normally C<$@> blessed into C<L<APR::Error
287
object|docs::2.0::api::APR::Error>>.
289
=item ret: C<$status> ( boolean )
295
Due to possible variants in conditions matching C<ECONNRESET>, the use
296
of this function is recommended for checking error codes against this
297
value, rather than just using
298
C<L<APR::Const::ECONNRESET|docs::2.0::api::APR::Const/C_APR__Const__ECONNRESET_>>
312
Check if the error is matching C<TIMEUP> and its variants (corresponds
313
to the C<APR_STATUS_IS_TIMEUP> macro).
315
$status = APR::Status::is_TIMEUP($error_code);
319
=item arg1: C<$error_code> (integer or C<L<APR::Error
320
object|docs::2.0::api::APR::Error>> )
322
The error code or to check, normally C<$@> blessed into C<L<APR::Error
323
object|docs::2.0::api::APR::Error>>.
325
=item ret: C<$status> ( boolean )
331
Due to possible variants in conditions matching C<TIMEUP>,
332
the use of this function is recommended for checking error codes
333
against this value, rather than just using
334
C<L<APR::Const::TIMEUP|docs::2.0::api::APR::Const/C_APR__Const__TIMEUP_>>
340
L<mod_perl 2.0 documentation|docs::2.0::index>.
345
mod_perl 2.0 and its core modules are copyrighted under
346
The Apache Software License, Version 2.0.
352
L<The mod_perl development team and numerous
353
contributors|about::contributors::people>.