[Date Prev][Date Next] [Chronological] [Thread] [Top]

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



  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
>
> >>> "Kurt D. Zeilenga" <Kurt@OpenLDAP.org> 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
>