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 50A838973 for ; Fri, 26 Aug 2011 14:09:02 +0000 (UTC) Received: (qmail 77046 invoked by uid 500); 26 Aug 2011 14:09:01 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 76890 invoked by uid 500); 26 Aug 2011 14:09:01 -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 76882 invoked by uid 99); 26 Aug 2011 14:09:00 -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 14:09:00 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [193.74.71.26] (HELO hel.is.scarlet.be) (193.74.71.26) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Aug 2011 14:08:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scarlet.be; s=scarlet; t=1314367712; bh=ESCsEG11vSj/VzEx2HQ4Th0duV8vD2vxzcMqaJaeTEk=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Transfer-Encoding:In-Reply-To; b=DezZw6YlKznEa0XjpHpisLOUsjcndfT8RltuHfATUtGCstdwggX+ncmdPqD7dSVzx pmZnRNGKnGNZxG2+blP1/UJow32QTCyfWU5iO0OyNAogv2z2FzhfWGCtwdTDqHn9Mm e+j1tlt7WG/9mVzxiSe/Al+U/I7aHmp2El0ugbkI= Received: from mail.harfang.homelinux.org (ip-62-235-218-185.dsl.scarlet.be [62.235.218.185]) by hel.is.scarlet.be (8.14.5/8.14.5) with ESMTP id p7QE8VdG008927 for ; Fri, 26 Aug 2011 16:08:32 +0200 X-Scarlet: d=1314367712 c=62.235.218.185 Received: from localhost (mail.harfang.homelinux.org [192.168.20.11]) by mail.harfang.homelinux.org (Postfix) with ESMTP id 0783D617FC for ; Fri, 26 Aug 2011 16:14:31 +0200 (CEST) Received: from mail.harfang.homelinux.org ([192.168.20.11]) by localhost (mail.harfang.homelinux.org [192.168.20.11]) (amavisd-new, port 10024) with ESMTP id bBskuvqBcDAL for ; Fri, 26 Aug 2011 16:14:28 +0200 (CEST) Received: from dusk.harfang.homelinux.org (mail.harfang.homelinux.org [192.168.20.11]) by mail.harfang.homelinux.org (Postfix) with ESMTP id 483F6617D6 for ; Fri, 26 Aug 2011 16:14:28 +0200 (CEST) Received: from eran by dusk.harfang.homelinux.org with local (Exim 4.76) (envelope-from ) id 1QwxAx-0004Vf-Vj for dev@commons.apache.org; Fri, 26 Aug 2011 16:14:28 +0200 Date: Fri, 26 Aug 2011 16:14:27 +0200 From: Gilles Sadowski To: dev@commons.apache.org Subject: Re: [math] Consistent use of ExceptionContext [was "using the ExceptionContext facility"] Message-ID: <20110826141427.GC16332@dusk.harfang.homelinux.org> Mail-Followup-To: dev@commons.apache.org References: <4E572E72.80001@gmail.com> <20110826104555.GA16332@dusk.harfang.homelinux.org> <20110826120530.GB16332@dusk.harfang.homelinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Operating-System: Tiny Tux X-PGP-Key-Fingerprint: 53B9 972E C2E6 B93C BEAD 7092 09E6 AF46 51D0 5641 User-Agent: Mutt/1.5.21 (2010-09-15) X-DCC-scarlet.be-Metrics: hel 20002; Body=1 Fuz1=1 Fuz2=1 X-Virus-Scanned: clamav-milter 0.97.1-exp at hel X-Virus-Status: Clean X-Virus-Checked: Checked by ClamAV on apache.org Hello. > > 2011/8/26 S�bastien Brisard > > > > > 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. > > > > More info attached to exceptions is great. I often find that the first half > of fixing a bug is adding more explicit exception throw/catch handling and > ever-more explicit messages, chasing the fault back to a root cause. > However, you have to ask who is going to be making use of the exception. Is > it someone who is debugging the library, or some user who's called into it > and somehow got broken behaviour? > > For debugging, you are familiar with your own library, and can capture info > about the state around where the exception was raised using your IDE in > debug mode. Your users aren't familiar with the library, and should be able > to tell from the exception message if it is most likely their fault (and if > so, how to fix it), or the library's (in which case they may send you the > stack-trace and we all know that better annotated exceptions make it easier > to interpret these even across different builds). > > So, personally I would lean on the side of as much explicit info in the > message as possible. "It was parameter A that borked me because it was XXX > and I was expecting YYY". Don't rely upon line numbers, because these change > as ppl edit the file and your users can understand 'A is borked' but can't > understand a line number. That's what is usually done when raising an exception: an explicit message contains the direct cause of the failure. What we discuss is how to propagate information that sometimes does not fit into a string message. > I wouldn't usually bother putting objects > capturing state describing the faulty environment into the exception as I > can get that from the debugger, given a test case. In my experience, a good > proportion of the real causes of exceptions aren't co-located with where the > exception is raised. Perhaps with the right cascades of exception handlers, > all of which capture their relevant local state, you can then serialize the > result out and have a pre-canned test-case for the failure. I'm not sure how > practical this would be in the real world - I expect you'd drown in > try/catch eventualities. You may be better logging the hinkey state very > close to where the exception is raised rather than storing references to it. In the case under consideration, logging the state is not an option, I think, because the default string representation of the operator might not be interesting and/or the full state might be too large. Thus the "manual" extraction which a knowledgeable user will control to save the state to an appropriate output. [Moreover, there is no logging in CM...] > > Happy to be proved wrong though. Perhaps this is the beginning of an era of > code that spits out bug unit tests when ever there are exceptions. At least, with the exception context, you can have access to the cause of the failure, and make a test out of it. Regards, Gilles --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org