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 22A1A8926 for ; Fri, 26 Aug 2011 13:45:03 +0000 (UTC) Received: (qmail 46185 invoked by uid 500); 26 Aug 2011 13:45:02 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 45999 invoked by uid 500); 26 Aug 2011 13:45: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 45989 invoked by uid 99); 26 Aug 2011 13:45:00 -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 13:45:00 +0000 X-ASF-Spam-Status: No, hits=4.0 required=5.0 tests=FREEMAIL_FROM,FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of turingatemyhamster@gmail.com designates 209.85.212.43 as permitted sender) Received: from [209.85.212.43] (HELO mail-vw0-f43.google.com) (209.85.212.43) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Aug 2011 13:44:56 +0000 Received: by vws10 with SMTP id 10so3878123vws.30 for ; Fri, 26 Aug 2011 06:44:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=4izEORJ4GuSsDZPDGSjaPWGPvo/nAuu0XhBkwBILyQs=; b=iIbPRLs5NNVvU0K5+DkOfWcNnxcwjL3w0hD/+kvLDhWYvo18b/jCP55lrUQmtlul5B 9mLIauVn1dM0h4Q9zSXySQixoCC/OYalpGfyNrb+L1oPSGvGPG39nCZN7WKN4Xh8j01k wewBqZwhV1XbtoUVtqfe4Lid/mt/wS2wFeTb0= MIME-Version: 1.0 Received: by 10.52.112.201 with SMTP id is9mr1108976vdb.379.1314366275392; Fri, 26 Aug 2011 06:44:35 -0700 (PDT) Received: by 10.52.113.106 with HTTP; Fri, 26 Aug 2011 06:44:35 -0700 (PDT) In-Reply-To: References: <4E572E72.80001@gmail.com> <20110826104555.GA16332@dusk.harfang.homelinux.org> <20110826120530.GB16332@dusk.harfang.homelinux.org> Date: Fri, 26 Aug 2011 14:44:35 +0100 Message-ID: Subject: Re: [math] Consistent use of ExceptionContext [was "using the ExceptionContext facility"] From: Matthew Pocock To: Commons Developers List Content-Type: multipart/alternative; boundary=bcaec547cc2bf3169704ab68be2a --bcaec547cc2bf3169704ab68be2a Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi, 2011/8/26 S=E9bastien 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 chang= e as ppl edit the file and your users can understand 'A is borked' but can't understand a line number. 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 th= e 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 ho= w 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= . 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. Matthew > Best regards, > S=E9bastien > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org > For additional commands, e-mail: dev-help@commons.apache.org > > --=20 Dr Matthew Pocock Visitor, School of Computing Science, Newcastle University mailto: turingatemyhamster@gmail.com gchat: turingatemyhamster@gmail.com msn: matthew_pocock@yahoo.co.uk irc.freenode.net: drdozer tel: (0191) 2566550 mob: +447535664143 --bcaec547cc2bf3169704ab68be2a--