Subject: Re: IllegalArgumentException (WG last call on the Java API)

From: "Steve Sonntag" <[email-masked]>
Date: Mon, 26 Mar 2001 15:45:47 -0700

Kurt,

Perhaps you could away with PARAM_ERROR
in favor of IllegalArgumentException - except that
IllegalArgumentException is a RuntimeException and
will terminate the application if not caught, where
an Application must catch LDAPException. Runtime
exceptions are not usually advertised in the Java doc
and are generally considered fatal errors.

I don't agree with doing away with all the other API specific
result codes. If you are serious about this then please
indiciate what standard Java exceptions can used to replace
them. For instance, REFERRAL_LIMIT_EXCEEDED
is specific to LDAP and has no corresponding Java
Exception. Replace with ???

-Steve

>>> "Kurt D. Zeilenga" <[email-masked]> 26-Mar-01 12:38:45 PM >>>
At 10:14 AM 3/26/01 -0700, Steve Sonntag wrote: 
>One thing that is confusing to me is the following:
> 
>When does a method throw LDAPException with PARAM_ERROR
> vs
>throwing IllegalArgumentException
> 
>I realize that the method in the discussion below
>does not throw LDAPException but many others do.
>How does one determine which of the two exceptions is thrown?

I'd suggest doing away with PARAM_ERROR and always
using IllegalArgumentException... In fact, I suggest
doing away with all LDAPExceptions with API specific
result codes in favor of other Exceptions.

Kurt

---

From: Rob Weltman <[email-masked]>
Date: Mon, 26 Mar 2001 14:58:20 -0800

LDAPException supports exception nesting, too, so that lower level exceptions can be propagated upwards.

  In general I think IllegalArgumentException (and maybe NullPointerException) are for operator error, i.e. the client passing invalid values to the API, while LDAPException reports a run-time error such as no server available or (as you mention) referral limit exceeded. A well-coded application must be prepared for such exceptions regardless of the context, while it may choose to validate parameters before passing them to the API rather than catching an IllegalArgumentException.

Rob

Steve Sonntag wrote:

>  Kurt, Perhaps you could away with PARAM_ERRORin favor of IllegalArgumentException - except thatIllegalArgumentException is a RuntimeException andwill terminate the application if not caught, wherean Application must catch LDAPException.  Runtimeexceptions are not usually advertised in the Java docand are generally considered fatal errors. I don't agree with doing away with all the other API specificresult codes.  If you are serious about this then pleaseindiciate what standard Java exceptions can used to replacethem.  For instance, REFERRAL_LIMIT_EXCEEDEDis specific to LDAP and has no corresponding JavaException.  Replace with ??? -Steve
>