Return-Path: Delivered-To: apmail-directory-api-archive@minotaur.apache.org Received: (qmail 907 invoked from network); 2 Jun 2010 05:42:52 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Jun 2010 05:42:52 -0000 Received: (qmail 38893 invoked by uid 500); 2 Jun 2010 05:42:52 -0000 Delivered-To: apmail-directory-api-archive@directory.apache.org Received: (qmail 38856 invoked by uid 500); 2 Jun 2010 05:42:51 -0000 Mailing-List: contact api-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: api@directory.apache.org Delivered-To: mailing list api@directory.apache.org Received: (qmail 38847 invoked by uid 99); 2 Jun 2010 05:42:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jun 2010 05:42:50 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.9] (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 02 Jun 2010 05:42:48 +0000 Received: (qmail 846 invoked from network); 2 Jun 2010 05:42:23 -0000 Received: from unknown (HELO ?IPv6:::1?) (127.0.0.1) by 127.0.0.1 with SMTP; 2 Jun 2010 05:42:23 -0000 Message-ID: <4C05EF3B.50005@apache.org> Date: Wed, 02 Jun 2010 07:42:19 +0200 From: Stefan Seelmann User-Agent: Thunderbird 2.0.0.24 (X11/20100411) MIME-Version: 1.0 To: api@directory.apache.org Subject: Re: Should the BIND throw an Exception ? References: <4C057D2E.2040108@gmail.com> In-Reply-To: <4C057D2E.2040108@gmail.com> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Emmanuel Lecharny wrote: > Hi guys, > > long time, no see ... Lots of side work going on, but still progressing > on the API. > > I have a question though : should the LdapConnection.bind()operation > throw an exception, or not ? > > Currently we have a version that returns a BindResponse, which is > convenient but a bit painful if you have got an error, as you have to > check the response before using the connection. > > Wouldn't it be better to just throw an LdapException, containing the > Bindresponse elements, � la JNDI ? > > wdyt ? Short answer: yes, let's throw an exception. I thought about it. There are two different paradigms: - LDAP returns status codes. Not each status code > 0 is an error. - In Java we are used to use Exceptions I already falled in this trap when I used the modify operation and I expected an exception but only received the response and had to check the response. Maybe we should take the list of all response codes and decide in which cases we throw an exception and in which cases we just return the response object. Additional we could make this list configurable by the user of the API and provide some predefined configurations (throw always, throw never, default settings). Here is my first try, feel free to comment: success (0), operationsError (1), --> Exception protocolError (2), --> Exception timeLimitExceeded (3), sizeLimitExceeded (4), compareFalse (5), compareTrue (6), authMethodNotSupported (7), --> Exception strongerAuthRequired (8), --> Exception -- 9 reserved -- referral (10), adminLimitExceeded (11), unavailableCriticalExtension (12), --> Exception confidentialityRequired (13), --> Exception saslBindInProgress (14), noSuchAttribute (16), --> Exception undefinedAttributeType (17), --> Exception inappropriateMatching (18), --> Exception constraintViolation (19), --> Exception attributeOrValueExists (20), --> Exception invalidAttributeSyntax (21), --> Exception -- 22-31 unused -- noSuchObject (32), --> Exception aliasProblem (33), --> Exception invalidDNSyntax (34), --> Exception -- 35 reserved for undefined isLeaf -- aliasDereferencingProblem (36), --> Exception -- 37-47 unused -- inappropriateAuthentication (48), --> Exception invalidCredentials (49), --> Exception insufficientAccessRights (50), --> Exception busy (51), --> Exception unavailable (52), --> Exception unwillingToPerform (53), --> Exception loopDetect (54), --> Exception -- 55-63 unused -- namingViolation (64), --> Exception objectClassViolation (65), --> Exception notAllowedOnNonLeaf (66), --> Exception notAllowedOnRDN (67), --> Exception entryAlreadyExists (68), --> Exception objectClassModsProhibited (69), --> Exception -- 70 reserved for CLDAP -- affectsMultipleDSAs (71), --> Exception -- 72-79 unused -- other (80), --> Exception Kind Regards, Stefan