Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4DD6E96FB for ; Mon, 5 Mar 2012 07:47:31 +0000 (UTC) Received: (qmail 26362 invoked by uid 500); 5 Mar 2012 07:47:30 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 24777 invoked by uid 500); 5 Mar 2012 07:47:25 -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 24718 invoked by uid 99); 5 Mar 2012 07:47:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Mar 2012 07:47:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Mar 2012 07:47:21 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 5CCF39AF0 for ; Mon, 5 Mar 2012 07:47:00 +0000 (UTC) Date: Mon, 5 Mar 2012 07:47:00 +0000 (UTC) From: "Simone Tripodi (Commented) (JIRA)" To: issues@commons.apache.org Message-ID: <1702520513.21626.1330933620381.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1093432856.20434.1330899899372.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (CHAIN-67) Refactor of explicit Exception throws to a RuntimeException type 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/CHAIN-67?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13222201#comment-13222201 ] Simone Tripodi commented on CHAIN-67: ------------------------------------- Patch looks more than good, I am going to apply it, thanks! > Refactor of explicit Exception throws to a RuntimeException type > ---------------------------------------------------------------- > > Key: CHAIN-67 > URL: https://issues.apache.org/jira/browse/CHAIN-67 > Project: Commons Chain > Issue Type: Improvement > Affects Versions: 2.0 > Reporter: Elijah Zupancic > Priority: Minor > Labels: exception-handling > Fix For: 2.0 > > Attachments: chain-67.diff > > Original Estimate: 2h > Remaining Estimate: 2h > > As I've been working on the examples and the documentation for v2 of > chain, I've noticed that the API for exception handling of Command and > Chain is clunky. > When executing a command like: > {code:java} > ProfileContext context = new ProfileContext(); > Command command = new ProfileCheck(); > try { > command.execute(context); > } > catch (Exception e) { > throw new RuntimeException(e); > } > {code} > The user of chain has to explicitly catch Exception. If the desire was > to catch the most base error and force the user to deal with it, why > aren't we using Throwable? Anyways, this design leads to less than > elegant code and since we will be breaking the API in v2, I would like > to suggest a different approach. > I suggest that Command and Chain should throw a custom exception class > called ChainException that inherits from RuntimeException. And in the > CommandBase, ChainBase we wrap the catch of Exception in this runtime > exception. Moreover, we would attach to ChainException some optional > debug information about the Context invoked when the exception was > encountered. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira