libapa...:Status(3pm)
β¨ APR::Status β bestie edition β¨
okay so real talk, this is the Perl interface situation for the APR_STATUS_IS_* macros π β that's libapa...:Status(3pm) if you're looking for it in the manual index, and it lives in the User Contributed Perl Documentation section. sit down, get comfy, we're gonna make error codes make sense π«Ά
πΈ NAME πΈ
APR::Status β Perl Interface to the APR_STATUS_IS_* macros
π Synopsis π
ngl the vibe here is: catch an exception, then check if it's actually the flavour of error you think it is π
use APR::Status ();
eval { $obj->mp_method() };
if ($@ && $ref $@ eq 'APR::Error' && APR::Status::is_EAGAIN($@)) {
# APR_STATUS_IS_EAGAIN(s) of apr_errno.h is satisfied
}
π¦ Description π¦
So this whole module is an interface to apr_errno.h composite error codes β¨ β the messy ones, the ones that are one error living in many bodies π
Like, the APR::Error manpage mentions you can handle APR/Apache/mod_perl exceptions like this:
eval { $obj->mp_method() };
if ($@ && $ref $@ eq 'APR::Error' && $@ == $some_code)
warn "handled exception: $@";
}
But π
here's the tea: when $some_code is an APR::Const constant, there can be more than one condition that satisfies the intent of that exception. It's giving "one concept, several error codes" π€
Which is exactly why the APR C library ships, in apr_errno.h, a whole series of macros: APR_STATUS_IS_*. Those are the recommended way to check for these conditions β no cap π₯
For example, the APR_STATUS_IS_EAGAIN macro is defined as:
#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \
|| (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \
|| (s) == APR_OS_START_SYSERR + SOCEWOULDBLOCK \
|| (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION)
see??? four different ways to be EAGAIN. she contains multitudes π
And the purpose of APR::Status is literally to provide functions corresponding to these macros. that's it, that's the whole job, and she does it beautifully π
π Functions π
π is_EACCES
Check if the error is matching EACCES and its variants (corresponds to the APR_STATUS_IS_EACCES macro) β¨
$status = APR::Status::is_EACCES($error_code);
- arg1:
$error_code(integer orAPR::Error object) β The error code or to check, normally$@blessed intoAPR::Error object. - ret:
$status( boolean ) - since: 2.0.00
An example of using is_EACCES is when reading the contents of a file where access may be forbidden π:
eval { $obj->slurp_filename(0) };
if ($@) {
return Apache2::Const::FORBIDDEN
if ref $@ eq 'APR::Error' && APR::Status::is_EACCES($@);
die $@;
}
Because EACCES can be satisfied by possible variants, the use of this function is recommended for checking error codes against this value β rather than just using APR::Const::EACCES directly. fr fr, use the macro π
π is_EAGAIN
Check if the error is matching EAGAIN and its variants (corresponds to the APR_STATUS_IS_EAGAIN macro) β¨
$status = APR::Status::is_EAGAIN($error_code);
- arg1:
$error_code(integer orAPR::Error object) β The error code or to check, normally$@blessed intoAPR::Error object. - ret:
$status( boolean ) - since: 2.0.00
For example, here is how you may want to handle socket read exceptions and do retries π:
use APR::Status ();
# ....
my $tries = 0;
my $buffer;
RETRY: my $rlen = eval { $socket->recv($buffer, SIZE) };
if ($@ && ref($@) && APR::Status::is_EAGAIN($@)) {
if ($tries++ < 3) {
goto RETRY;
}
else {
# do something else
}
}
else {
die "eval block has failed: $@";
}
β οΈ bestie listen. just checking againstAPR::Const::EAGAINmay work on some Unices, but then it will certainly break on win32 π so make sure to use this macro and notAPR::Const::EAGAINunless you know what you are doing. periodt π
π is_ENOENT
Check if the error is matching ENOENT and its variants (corresponds to the APR_STATUS_IS_ENOENT macro) β¨
$status = APR::Status::is_ENOENT($error_code);
- arg1:
$error_code(integer orAPR::Error object) β The error code or to check, normally$@blessed intoAPR::Error object. - ret:
$status( boolean ) - since: 2.0.00
An example of using is_ENOENT is when reading the contents of a file which may not exist π»:
eval { $obj->slurp_filename(0) };
if ($@) {
return Apache2::Const::NOT_FOUND
if ref $@ eq 'APR::Error' && APR::Status::is_ENOENT($@);
die $@;
}
Because ENOENT can be satisfied by possible variants, the use of this function is recommended for checking error codes against this value β rather than just using APR::Const::ENOENT directly π
π is_EOF
Check if the error is matching EOF and its variants (corresponds to the APR_STATUS_IS_EOF macro) β¨
$status = APR::Status::is_EOF($error_code);
- arg1:
$error_code(integer orAPR::Error object) β The error code or to check, normally$@blessed intoAPR::Error object. - ret:
$status( boolean ) - since: 2.0.00
Because EOF can be satisfied by possible variants, the use of this function is recommended for checking error codes against this value β rather than just using APR::Const::EOF directly πΈ
π is_ECONNABORTED
Check if the error is matching ECONNABORTED and its variants (corresponds to the APR_STATUS_IS_ECONNABORTED macro) β¨
$status = APR::Status::is_ECONNABORTED($error_code);
- arg1:
$error_code(integer orAPR::Error object) β The error code or to check, normally$@blessed intoAPR::Error object. - ret:
$status( boolean ) - since: 2.0.00
Because ECONNABORTED can be satisfied by possible variants, the use of this function is recommended for checking error codes against this value β rather than just using APR::Const::ECONNABORTED directly π
π is_ECONNRESET
Check if the error is matching ECONNRESET and its variants (corresponds to the APR_STATUS_IS_ECONNRESET macro) β¨
$status = APR::Status::is_ECONNRESET($error_code);
- arg1:
$error_code(integer orAPR::Error object) β The error code or to check, normally$@blessed intoAPR::Error object. - ret:
$status( boolean ) - since: 2.0.00
Because ECONNRESET can be satisfied by possible variants, the use of this function is recommended for checking error codes against this value β rather than just using APR::Const::ECONNRESET directly π§
π is_TIMEUP
Check if the error is matching TIMEUP and its variants (corresponds to the APR_STATUS_IS_TIMEUP macro) β¨
$status = APR::Status::is_TIMEUP($error_code);
- arg1:
$error_code(integer orAPR::Error object) β The error code or to check, normally$@blessed intoAPR::Error object. - ret:
$status( boolean ) - since: 2.0.00
Because TIMEUP can be satisfied by possible variants, the use of this function is recommended for checking error codes against this value β rather than just using APR::Const::TIMEUP directly β°
π See Also π
mod_perl 2.0 documentation. go read it, iykyk π
π Copyright π
mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0.
π«Ά Authors π«Ά
The mod_perl development team and numerous contributors.
okay that's the whole page bestie, you ate it up π mwah π
signing off β this was perl v5.42.3, dated 2026-08-20, from the libapa...:Status(3pm) page πβ¨π
π¦ where this page comes from
- ubuntu stonking: libapache2-mod-perl2 2.0.13-2build3 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms