From dev-return-123840-apmail-commons-dev-archive=commons.apache.org@commons.apache.org Tue Feb 01 14:39:39 2011 Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 74246 invoked from network); 1 Feb 2011 14:39:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Feb 2011 14:39:39 -0000 Received: (qmail 8324 invoked by uid 500); 1 Feb 2011 14:39:38 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 7719 invoked by uid 500); 1 Feb 2011 14:39:34 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 7711 invoked by uid 99); 1 Feb 2011 14:39:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Feb 2011 14:39:33 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jodastephen@gmail.com designates 209.85.216.43 as permitted sender) Received: from [209.85.216.43] (HELO mail-qw0-f43.google.com) (209.85.216.43) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Feb 2011 14:39:27 +0000 Received: by qwk3 with SMTP id 3so6582364qwk.30 for ; Tue, 01 Feb 2011 06:39:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=YvSbVcEGPsFbK+BPmWxAryvAzS9F4NBwRQTPHTY1dls=; b=Ob+I26OmPeps0bOo2Sgoyp+YGaiX0gkmDrgUBc9Lrwx3MgdXyA/7HHLZ6MKKZl+nVT L/YwKn2cGRAPYUq/6g854x8lvBpYral8BGQVV0/J0GV6C60pVHMyOXZCpJd7hiBPvoEh JLPqfAKvLVHHa7N/z/Lox7SguIxDDKQmr00VM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=RbFFr72+Xu12OkElCJa3oE5AFBkcG5bEKp6X640PI17XCTLCFj/w7fp7havXm219pW N2RtmPIT7aRKc4vlgJgphT+ZTXkW+YMZUznsbi7bTdx4Qg8j9pMlt19JAR1j6W/OgAvi aaM/D0XbyX/tdVYNI/EXMt+wBBJu6ad8glZ9g= MIME-Version: 1.0 Received: by 10.229.193.204 with SMTP id dv12mr5284373qcb.274.1296571146137; Tue, 01 Feb 2011 06:39:06 -0800 (PST) Sender: jodastephen@gmail.com Received: by 10.229.99.8 with HTTP; Tue, 1 Feb 2011 06:39:06 -0800 (PST) In-Reply-To: <1969100260.1391011296568344161.JavaMail.root@spooler6-g27.priv.proxad.net> References: <1306776012.1389141296568027913.JavaMail.root@spooler6-g27.priv.proxad.net> <1969100260.1391011296568344161.JavaMail.root@spooler6-g27.priv.proxad.net> Date: Tue, 1 Feb 2011 14:39:06 +0000 X-Google-Sender-Auth: R8RnMQycaNk6YyytkLSIaCwJG7I Message-ID: Subject: Re: [all][math] Help wanted with exceptions API design From: Stephen Colebourne To: Commons Developers List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On 1 February 2011 13:52, wrote: >> I have a small hierarchy of exceptions that attempts to capture some >> key problems that may occur. The problem I found was that as I >> refactored code, the exceptions listed in Javadoc quickly became >> inaccurate. As a result, I've started converting many exceptions to >> the parent CalendricalException. If a method returns a subclasses of >> CalEx then thats fine and provides more info. But documenting it as >> returning the subclass is way too much work for limited gain. > > So users who want to extract data put in their code statements along > the line of : if (e instanceof subClassException) =A0{ ... } ? You can always catch a sub-exception even if the documentation only says it throws the super-exception. >> Info on failure simply needs a good message in English. > > No. Some people do not read English at all. In many systems a strong > requirement is that every message users can see must be localizable. > Localizing a message that has variable parts (numerical values, > strings, booleans) after the message has been built on a top level layer > is impossible. I don't believe that the cost is worth it. But thats a project decision. One impact of the cost is interminable exception discussions... >> to diagnose the problem in a stack trace. > > No. End users are not always developers, or they may have no access to th= e > source code, or they may not know the architecture of the applications, > they may even not known Commons Math is used behind the scenes in a low > level layer. Stack trace are not for users and we should not rely on them= . A good message was the point, and should be usable without the stack trace. On 1 February 2011 13:47, Gilles Sadowski wr= ote: > Here we (in CM) arrived to the consensus that it would be simpler to have > all our exceptions rooted at "RuntimeException". Unfortunately, that make= s > us depart from the other standard exceptions. For example, we created a > "MathIllegalArgumentException" that is not a subclass of the standard > "IllegalArgumentException" although it is semantically equivalent. > This decision was indeed partly due to the complication induced by the > localization "framework" (to avoid code duplication). I maintain that IllegalArgumentException should be used as is. Anything else is rather confusing, and a "it avoids code duplication" argument isn't good enough for me. Stephen --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org