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 9E8CD9237 for ; Sun, 4 Mar 2012 04:08:27 +0000 (UTC) Received: (qmail 75212 invoked by uid 500); 4 Mar 2012 04:08:26 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 75054 invoked by uid 500); 4 Mar 2012 04:08:26 -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 75035 invoked by uid 99); 4 Mar 2012 04:08:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Mar 2012 04:08:26 +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 (athena.apache.org: domain of elijahzupancic@gmail.com designates 209.85.213.171 as permitted sender) Received: from [209.85.213.171] (HELO mail-yx0-f171.google.com) (209.85.213.171) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Mar 2012 04:08:19 +0000 Received: by yenl11 with SMTP id l11so2729353yen.30 for ; Sat, 03 Mar 2012 20:07:59 -0800 (PST) Received-SPF: pass (google.com: domain of elijahzupancic@gmail.com designates 10.236.184.226 as permitted sender) client-ip=10.236.184.226; Authentication-Results: mr.google.com; spf=pass (google.com: domain of elijahzupancic@gmail.com designates 10.236.184.226 as permitted sender) smtp.mail=elijahzupancic@gmail.com; dkim=pass header.i=elijahzupancic@gmail.com Received: from mr.google.com ([10.236.184.226]) by 10.236.184.226 with SMTP id s62mr20732552yhm.104.1330834079244 (num_hops = 1); Sat, 03 Mar 2012 20:07:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:x-google-sender-auth:message-id :subject:to:content-type; bh=HVADd1GQsLNc5yzsKIc60/8iLv1ydqp1248+70vWGIA=; b=v2IuBawb6zPR3w9Ouo68rB5SUkfCG6OUTG33KuBAd1NwSFML6E6IIeiNnsn/4eSE4j IjuyiO1OckVCz8xpkKfQ9sGEarcDNoIjGICKTCzbXDOOMLpHxrSrSYLLVBVV5OCEfBir POpcSi3uaNtHXHjgSJngJm8q7PmEJa0X9ilr2c26QOCKe2N0NhNeWVeMshxsi41Lovzq cvDdzZWIawW9Lzgj44oO1r55fXATeE5pZx5+unmXV4UdQcCj7+G4HqQUvXctYWZrkuvi GU/x8BfthDVBwYkDXuMnE0I7B2Cc2j336CXH7oIUXTtbPlJKKAvF82ARsCfFz0Z0xqM7 jn7Q== Received: by 10.236.184.226 with SMTP id s62mr16467090yhm.104.1330834079206; Sat, 03 Mar 2012 20:07:59 -0800 (PST) MIME-Version: 1.0 Sender: elijahzupancic@gmail.com Received: by 10.236.152.97 with HTTP; Sat, 3 Mar 2012 20:07:39 -0800 (PST) From: Elijah Zupancic Date: Sat, 3 Mar 2012 20:07:39 -0800 X-Google-Sender-Auth: pmGYOxF_MTr4knwTaDEet7m4VA8 Message-ID: Subject: [chain] Changing from Exception to RuntimeException To: Commons Developers List Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org 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: ProfileContext context = new ProfileContext(); Command command = new ProfileCheck(); try { command.execute(context); } catch (Exception e) { throw new RuntimeException(e); } 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. If anyone thinks that this is a good idea, I can whip up a patch quickly. Thanks, -Elijah --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org