You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Justin Erenkrantz <je...@ebuilt.com> on 2001/08/01 05:11:59 UTC

Re: apr-util + LDAP: How to handle status codes

On Tue, Jul 31, 2001 at 11:15:31AM +0200, Graham Leggett wrote:
> Is this the right way to do things? Or should there be a mapping to
> APR_LDAP_* status codes from LDAP_* status codes?

I'd suggest that we should map the APR_LDAP_* status codes from LDAP_*.
We can do this by allocating an offset.  So, just do:

apr_status_t status = ldap_fn_result_code + APR_LDAP_ERROR_START;

or something like that.  We have that precedent somewhere.  How many
numbers would we need?  I don't remember how many the LDAP library
defines.  -- justin


Re: apr-util + LDAP: How to handle status codes

Posted by Justin Erenkrantz <je...@ebuilt.com>.
On Wed, Aug 01, 2001 at 05:09:03PM +0200, Graham Leggett wrote:
> Ian Holsman wrote:
> 
> > I mentioned this a while back
> > (as I too would like 1 apr_strerror to register callbacks) but
> > the consensus was that each library should take care of it self
> 
> This is yucky - often you want a generic error handling that will print
> an error regardless of whether it originated in the OS, or some other
> library.

While I think rbb had some suggestion for handling extension of APR's
error codes (did you?), on retrospect, it is probably better just to 
have your own APR_LDAP_ERROR_* #defines.  And, your own
apr_ldap_strtoerror.  

I can't think of a better solution right now.  -- justin


Re: apr-util + LDAP: How to handle status codes

Posted by Ryan Bloom <rb...@covalent.net>.
On Wednesday 01 August 2001 08:09, Graham Leggett wrote:
> Ian Holsman wrote:
> > I mentioned this a while back
> > (as I too would like 1 apr_strerror to register callbacks) but
> > the consensus was that each library should take care of it self
>
> This is yucky - often you want a generic error handling that will print
> an error regardless of whether it originated in the OS, or some other
> library.

It doesn't make any sense to have a single library try to implement a strerror like call
for everything.  The application knows what kind of function it just called, so it knows
the correct strerror function to call.

Ryan
_____________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
Covalent Technologies			rbb@covalent.net
-----------------------------------------------------------------------------

Re: apr-util + LDAP: How to handle status codes

Posted by Graham Leggett <mi...@sharp.fm>.
Ian Holsman wrote:

> I mentioned this a while back
> (as I too would like 1 apr_strerror to register callbacks) but
> the consensus was that each library should take care of it self

This is yucky - often you want a generic error handling that will print
an error regardless of whether it originated in the OS, or some other
library.

Regards,
Graham
-- 
-----------------------------------------
minfrin@sharp.fm		"There's a moon
					over Bourbon Street
						tonight..."

Re: apr-util + LDAP: How to handle status codes

Posted by Ian Holsman <ia...@cnet.com>.
On 01 Aug 2001 03:49:22 -0700, Graham Leggett wrote:
> Ian Holsman wrote:
> 
> > would it be possible to have a apr_ldap_errstr( apr_status_t )
> function
> > which would
> > convert the numbers into messages?
> 
> There is already an apr_strerror() function to do this. Would it not
> make sense to somehow have this function include the ldap_err2string()
> function for errors in the LDAP range?
> 
> How would this be achieved when apr_strerror() is in APR, and the LDAP
> stuff is in APR-util?
> 
> Could a callback not be introduced to apr_strerror() which allows a
> specific function to be called to return string errors for certain
> number ranges? The APR-util code would then set this callback function
> to point at ldap_err2string()?

I mentioned this a while back 
(as I too would like 1 apr_strerror to register callbacks) but 
the consensus was that each library should take care of it self

so I didn't proceed with a patch
> 
> Regards,
> Graham
> -- 
> -----------------------------------------
> minfrin@sharp.fm		"There's a moon
> 					over Bourbon Street
> 						tonight..."
-- 
Ian Holsman
Performance Measurement & Analysis
CNET Networks    -    415 364-8608


Re: apr-util + LDAP: How to handle status codes

Posted by Graham Leggett <mi...@sharp.fm>.
Ian Holsman wrote:

> would it be possible to have a apr_ldap_errstr( apr_status_t ) function
> which would
> convert the numbers into messages?

There is already an apr_strerror() function to do this. Would it not
make sense to somehow have this function include the ldap_err2string()
function for errors in the LDAP range?

How would this be achieved when apr_strerror() is in APR, and the LDAP
stuff is in APR-util?

Could a callback not be introduced to apr_strerror() which allows a
specific function to be called to return string errors for certain
number ranges? The APR-util code would then set this callback function
to point at ldap_err2string()?

Regards,
Graham
-- 
-----------------------------------------
minfrin@sharp.fm		"There's a moon
					over Bourbon Street
						tonight..."

Re: apr-util + LDAP: How to handle status codes

Posted by Ian Holsman <ia...@cnet.com>.
Justin Erenkrantz wrote:

>On Tue, Jul 31, 2001 at 11:15:31AM +0200, Graham Leggett wrote:
>
>>Is this the right way to do things? Or should there be a mapping to
>>APR_LDAP_* status codes from LDAP_* status codes?
>>
>
>I'd suggest that we should map the APR_LDAP_* status codes from LDAP_*.
>We can do this by allocating an offset.  So, just do:
>
>apr_status_t status = ldap_fn_result_code + APR_LDAP_ERROR_START;
>
>or something like that.  We have that precedent somewhere.  How many
>numbers would we need?  I don't remember how many the LDAP library
>defines.  -- justin
>


would it be possible to have a apr_ldap_errstr( apr_status_t ) function 
which would
convert the numbers into messages?



Re: apr-util + LDAP: How to handle status codes

Posted by Graham Leggett <mi...@sharp.fm>.
Justin Erenkrantz wrote:

> > Is this the right way to do things? Or should there be a mapping to
> > APR_LDAP_* status codes from LDAP_* status codes?
> 
> I'd suggest that we should map the APR_LDAP_* status codes from LDAP_*.
> We can do this by allocating an offset.  So, just do:
> 
> apr_status_t status = ldap_fn_result_code + APR_LDAP_ERROR_START;
> 
> or something like that.  We have that precedent somewhere.  How many
> numbers would we need?  I don't remember how many the LDAP library
> defines.  -- justin

There are about 100 or so (as a guess).

A potential problem though - apr_error.h is defined in APR. The LDAP_*
error codes are only defined if the LDAP libraries are included in
apr-util.

Would the APR_LDAP_* codes go in APR or APR-util? (they could
practically only go in the second one).

Would the right approach then be to define APR_LDAP_ERROR_START in APR,
and then the actual error codes themselves in APR-util? (in apr_ldap.h,
or something else?).

Regards,
Graham
-- 
-----------------------------------------
minfrin@sharp.fm		"There's a moon
					over Bourbon Street
						tonight..."