Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 68657 invoked from network); 27 Apr 2009 21:12:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Apr 2009 21:12:52 -0000 Received: (qmail 33882 invoked by uid 500); 27 Apr 2009 21:12:52 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 33786 invoked by uid 500); 27 Apr 2009 21:12:52 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 33735 invoked by uid 99); 27 Apr 2009 21:12:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Apr 2009 21:12:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Apr 2009 21:12:51 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id CB105234C003 for ; Mon, 27 Apr 2009 14:12:30 -0700 (PDT) Message-ID: <1335850396.1240866750816.JavaMail.jira@brutus> Date: Mon, 27 Apr 2009 14:12:30 -0700 (PDT) From: "Derek C. Ashmore (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (LANG-497) Addition of ContextedException and ContextedRuntimeException In-Reply-To: <748207102.1240652010305.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/LANG-497?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12703378#action_12703378 ] Derek C. Ashmore commented on LANG-497: --------------------------------------- Hi Joerg, My apologies, my IDE puts those copyright notices in automatically. I'll remove them, put in the appropriate header and fill out the remaining unit tests. You'll see a resubmission from me with these items within 48 hrs. Thanks for working with me on this. Derek > Addition of ContextedException and ContextedRuntimeException > ------------------------------------------------------------ > > Key: LANG-497 > URL: https://issues.apache.org/jira/browse/LANG-497 > Project: Commons Lang > Issue Type: New Feature > Reporter: Derek C. Ashmore > Fix For: 3.0 > > Attachments: ContextedException.java, ContextedExceptionTest.java, ContextedRuntimeException.java, ContextedRuntimeExceptionTest.java, DefaultExceptionContext.java, ExceptionContext.java > > > This is a proposal for a feature addition. > These additional exceptions (checked and unchecked versions) provide an easier and safer > way for developers to provide context when generating checked exceptions. Often, > additional information, besides what's embedded in the exception cause, is needed > for developers to debug and correct a bug. Often, this additional information can > reduce the time it takes to replicate and fix a bug. > ContextedException are easier as developers don't need to be concerned > with formatting the exception message to include additional information > with the exception. Additional information is automatically included > in the message and printed stack trace. This often thins out exception > handling code. > ContextedException is safer as the additional code needed to embed additional > information in a normal exception tends to be tested less and is more vulnerable > to errors such as null pointer exceptions. > An unchecked version of this exception is provided by ContextedRuntimeException. > To use this class write code as follows: > > try { > ... > } catch (Throwable e) { > throw new ContextedException("Error posting account transaction", e) > .addLabeledValue("accountNumber", accountNumber) > .addLabeledValue("amountPosted", amountPosted) > .addLabeledValue("previousBalance", previousBalance) > } > } > The value of the context information is automatically included in the exception message and > when the stack trace is printed in the log. > My motivation for contributing is that I've previous versions of this running > at four clients now -- I'm tiered of copying this from client to client. > I've attached the two exceptions themselves along with working test cases. Every effort has been made > to adhere to your existing style, conventions, and standards. No changes are needed for any > existing files. > I ran the site generation -- These additions pass your checkstyle reports. > To streamline the committers time, I'll be happy to make any needed changes to to get this > into 3.0. > I know you're busy -- thanks for taking the time to at least review this proposal. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.