apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject APR_OS_START_USERERR regulation
Date Sun, 02 May 2004 20:13:00 GMT
APR_OS_START_USERERR are reserved for applications that use APR that
  *     layer their own error codes along with APR's.  Note that the
  *     error immediately following this one is set ten times farther
  *     away than usual, so that users of apr have a lot of room in
  *     which to declare custom error codes.

So if I want to use my own error codes in a module (e.g. modperl-2.0) and not 
application, how do I make sure that my error codes don't collide with another 
3rd party module when loaded together? Or is it because I'm not supposed to 
call apr_strerror for custom errors at all, then there is no problem at all. 
Is that right? That APR_OS_START_USERERR +10*APR_OS_ERRSPACE_SIZE range is 
simply available for applications/modules to have a single status variable 
such that both, apr, os and custom errors can re-use without overlapping? So 
if let's say mod_php and mod_perl both define some error code 
APR_OS_START_USERERR+1, there is no problem.

Really I was looking at some place where I can define my own map of 
code/string pairs and still reuse apr_strerror. I suppose the right way to go 
is to define a wrapper function:

char * my_strerror(apr_status_t statcode, char *buf, apr_size_t bufsize)
     if (statcode < APR_OS_START_USERERR) {
         return apr_strerror(statcode, buf, bufsize);
     else {
         /* handle custom errors here */

Is that the right way to go?

Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

View raw message