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 6C2A7843D for ; Fri, 26 Aug 2011 06:16:01 +0000 (UTC) Received: (qmail 24501 invoked by uid 500); 26 Aug 2011 06:15:58 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 23839 invoked by uid 500); 26 Aug 2011 06:15:49 -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 23829 invoked by uid 99); 26 Aug 2011 06:15:44 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Aug 2011 06:15:44 +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 sebastien.brisard@gmail.com designates 209.85.220.171 as permitted sender) Received: from [209.85.220.171] (HELO mail-vx0-f171.google.com) (209.85.220.171) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Aug 2011 06:15:36 +0000 Received: by vxh13 with SMTP id 13so3052410vxh.30 for ; Thu, 25 Aug 2011 23:15:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; 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; bh=QBOppBZkcqsbbiVyShwS8wW0+ZGli1H+m2E3ytKiUrw=; b=CTSGMebD9vd21pKzr9VdQk/WI3p1qVPvTbmvaHAmWCsXPT/sndi+fzE2CQpv81TWzS tJjNhU3kUlWEvHL4SlHUyzYGKJ0MY038Zpy4KtoPsPFY+CWT02HPoqpipYUSfGydZOOf rNKWIZ9dzIWd37T8Sl0jHst7xSAlMRwmDseC8= MIME-Version: 1.0 Received: by 10.52.24.9 with SMTP id q9mr814319vdf.54.1314339315732; Thu, 25 Aug 2011 23:15:15 -0700 (PDT) Sender: sebastien.brisard@gmail.com Received: by 10.220.188.134 with HTTP; Thu, 25 Aug 2011 23:15:15 -0700 (PDT) In-Reply-To: <4E572E72.80001@gmail.com> References: <4E572E72.80001@gmail.com> Date: Fri, 26 Aug 2011 08:15:15 +0200 X-Google-Sender-Auth: UFQx_6irZ-JGnq-K0hn1V1FWm9I Message-ID: Subject: Re: [math] Consistent use of ExceptionContext [was "using the ExceptionContext facility"] From: =?ISO-8859-1?Q?S=E9bastien_Brisard?= 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 Hi, > > 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. > I do apologize, I am not sure I fully understand. Please let me try again. I agree, parsing e.getMessage() would be horrible, but that was not what I had in mind. Let's say that a NonPositiveDefiniteLinearOperatorException e is raised, and I want to retrieve the operator in question. One way to do it would be to have a getter e.getOffendingLinearOperator() In MATH-581, following the discussion entitled "Implementation of Conjugate Gradient (MATH-581)" (started aug, 4), we finally went for the more flexible e.getContext().getValue("offending operator") The issue then is a proper handling of the key names ("offending operator" in the present case). Should the key names be assigned arbitrarily by the method which throws the exception, or stored (as a constant String) in the exception itself. My point is that in some circumstances, it is possible to have the exception store "typical" keys, which can be consistently used by everyone throwing such an exception, with the further possibility to add supplementary context to this exception, with freely chosen key names. Is it what you understood from my previous message? Best regards, S=E9bastien --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org