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 or APR::Error object ) β€” The error code or to check, normally $@ blessed into APR::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 or APR::Error object ) β€” The error code or to check, normally $@ blessed into APR::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 against APR::Const::EAGAIN may work on some Unices, but then it will certainly break on win32 😭 so make sure to use this macro and not APR::Const::EAGAIN unless 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 or APR::Error object ) β€” The error code or to check, normally $@ blessed into APR::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 or APR::Error object ) β€” The error code or to check, normally $@ blessed into APR::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 or APR::Error object ) β€” The error code or to check, normally $@ blessed into APR::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 or APR::Error object ) β€” The error code or to check, normally $@ blessed into APR::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 or APR::Error object ) β€” The error code or to check, normally $@ blessed into APR::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 πŸ“š


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