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 6C08F8A73 for ; Fri, 26 Aug 2011 12:24:10 +0000 (UTC) Received: (qmail 18511 invoked by uid 500); 26 Aug 2011 12:24:08 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 18015 invoked by uid 500); 26 Aug 2011 12:24:05 -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 18006 invoked by uid 99); 26 Aug 2011 12:24:04 -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 12:24:04 +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 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 12:23:57 +0000 Received: by vxh13 with SMTP id 13so3404671vxh.30 for ; Fri, 26 Aug 2011 05:23:36 -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=bPmT3lLNiTLgxlkDBeLbh+Qk/lnMTokjIYTfV/2RRy8=; b=vaQMcLiioOhUYxY0XcfiGMPqrhYt7/q6D76aVifLoqjbKKYgvfxclrCl44mvbmqpRw WGAS/lvCID2NGuPDJ0r8nGxTxanRPjsbdCeSIKrahE8J2rczx8ljBYp1meqjSONr7GMM 9uHz98wqoewZaGdlsnlhLWb2TIIEKaxoIsQio= MIME-Version: 1.0 Received: by 10.52.67.108 with SMTP id m12mr982219vdt.121.1314361416494; Fri, 26 Aug 2011 05:23:36 -0700 (PDT) Sender: sebastien.brisard@gmail.com Received: by 10.220.188.134 with HTTP; Fri, 26 Aug 2011 05:23:36 -0700 (PDT) In-Reply-To: <20110826120530.GB16332@dusk.harfang.homelinux.org> References: <4E572E72.80001@gmail.com> <20110826104555.GA16332@dusk.harfang.homelinux.org> <20110826120530.GB16332@dusk.harfang.homelinux.org> Date: Fri, 26 Aug 2011 14:23:36 +0200 X-Google-Sender-Auth: IivcxH2HjfGjaJUmmlFSTXJJnWE 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 > > Do you mean that the context info for a (hyptohetical) method like > =A0doSomething(LinearOperator a, LinearOperator b) > would be like > =A0offending operator: a > or > =A0offending operator: b > ? > > If so, is it not enough to just throw the exception? Won't it be obvious > which operator is "offending" by looking at the line number in the stack > trace? > In your example, the answer is definitely yes. And from this point of view, using context is probably a very flexible solution, because we would provide some context only where it would really be needed : sometimes, a reference to the offending operator would certainly be useless. Thus, in your example, if the exception is some sort of DimensionMismatchException, I do not really need to know more than : a (or b) has wrong dimensions. Fix is easy. But I can think of other cases where the answer is probably no. For example, let us consider the Unpreconditioned Conjugate Gradient method. In this case, if a NonPositiveDefiniteLinearOperator is thrown, there is no ambiguity as to which operator is the cause (there is only one operator). However, the context would also hold a reference to the offending vector x, which could be invaluable. Let's assume I have proved mathematically that a (huge) linear operator a is positive definite. I go on implementing it, and pass it to the CG method, which throws a NonPositiveDefiniteLinearOperator. This means that during the iterations, the solver has found this rare counter-example x which proves that my implementation is faulty (x is such that x'.a.x <=3D 0). Just knowing that my implementation has a bug is already quite good. But retrieving a *reference* to the offending vector x would allow me to reproduce the bug *outside* the iterations of the CG solver. In other words, having this kind of context with documented keys would help the end-user debug his own code. I hope I'm making my point clearly, there. Best regards, S=E9bastien --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org