Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3273889E5 for ; Fri, 26 Aug 2011 05:27:10 +0000 (UTC) Received: (qmail 77506 invoked by uid 500); 26 Aug 2011 05:27:08 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 77306 invoked by uid 500); 26 Aug 2011 05:26:52 -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 77275 invoked by uid 99); 26 Aug 2011 05:26:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Aug 2011 05:26:45 +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 (athena.apache.org: domain of phil.steitz@gmail.com designates 209.85.161.171 as permitted sender) Received: from [209.85.161.171] (HELO mail-gx0-f171.google.com) (209.85.161.171) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Aug 2011 05:26:35 +0000 Received: by gxk22 with SMTP id 22so3228582gxk.30 for ; Thu, 25 Aug 2011 22:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=z70+0klnWgwA13YHcQvLqqCS6Tmrc5rGLJ7dbMYUsQQ=; b=p43O9kZDqbfr80a5iujfFlxmtfGw/EBin+SIa4Zzis5NL+fDxp5c6a8GvoMu6/Pw8H P7zHyh8jLl5J4XP66tG5yhnaEPzVywKYjIgry1b+Dfbap3X+UtOL4NfFnQfDR+F4rsXs 0vQgiTrNLRDxTTZ5YbzThTRKyLKnllzc70/x8= Received: by 10.43.131.138 with SMTP id hq10mr677300icc.181.1314336374764; Thu, 25 Aug 2011 22:26:14 -0700 (PDT) Received: from [192.168.0.2] (71-223-78-169.phnx.qwest.net [71.223.78.169]) by mx.google.com with ESMTPS id a9sm629878ibi.43.2011.08.25.22.26.12 (version=SSLv3 cipher=OTHER); Thu, 25 Aug 2011 22:26:13 -0700 (PDT) Message-ID: <4E572E72.80001@gmail.com> Date: Thu, 25 Aug 2011 22:26:10 -0700 From: Phil Steitz User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0) Gecko/20110812 Thunderbird/6.0 MIME-Version: 1.0 To: Commons Developers List Subject: Re: [math] Consistent use of ExceptionContext [was "using the ExceptionContext facility"] References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit On 8/25/11 8:47 PM, S�bastien Brisard wrote: > Hi, > a while ago, I started a thread on the "proper" of keys in > ExceptionContext. This message was too vague, and raised very (very) > little interest. Hope this one will be more successful... I now have a > suggestion, which would work in at least some cases. > > Very briefly, the issue is the following: the key names are attributed > by the method which throws the exception (say iThrowTheException()). > Now, the problem is: how does the method which catches the exception > (say iCatchTheException()) make sense out of this key name? The answer > would be to document the key names in the javadoc of > iThrowTheException(). While very flexible this approach does not > guarantee a minimum level of consistency. > > In some cases though, the potential context of a specific exception is > known beforehand. For example, in > o.a.c.m.linear.NonPositiveDefiniteLinearOperator, the context might be > the so-called offending operator and offending vector. Then, I propose > that key names be stored as public final static String and documented > *in the exception definition*. For example, in > NonPositiveDefiniteLinearOperator, we would have two constants > public final static String OPERATOR = "operator" > public final static String VECTOR = "vector" > > Thanks for your comments! We have, I think it is fair to say, diverse views in the community on the proper use of exception messages. One thing that I think we all agree on; however, is that we should not be designing exceptions or APIs that throw exceptions with the intent that applications catching exceptions should parse the messages or search the message content for specific strings. Those of us who like to include informative exception error messages expect these to be logged or visually inspected, not handled by client code. The vast majority of valuable use cases for exception error messages are in debugging code in development or diagnosing system failures, where context-rich error messages can be invaluable. At runtime, the type of the exception and any state that it holds in member fields (not including the message) should be all that client code needs to know to handle it. Therefore, I don't think it is necessary to repeat all of the exception message strings in the API documentation for the methods that may generate exceptions. Following standard conventions, we should just fully document what exceptions may be thrown and under which conditions these exceptions will be thrown. Phil > S�bastien > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org > For additional commands, e-mail: dev-help@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org