From mime4j-dev-return-2419-archive-asf-public=cust-asf.ponee.io@james.apache.org Wed May 23 12:23:07 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 032FC18067E for ; Wed, 23 May 2018 12:23:06 +0200 (CEST) Received: (qmail 88745 invoked by uid 500); 23 May 2018 10:23:06 -0000 Mailing-List: contact mime4j-dev-help@james.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: mime4j-dev@james.apache.org Delivered-To: mailing list mime4j-dev@james.apache.org Received: (qmail 88079 invoked by uid 99); 23 May 2018 10:23:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 May 2018 10:23:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 93760180789 for ; Wed, 23 May 2018 10:23:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.591 X-Spam-Level: X-Spam-Status: No, score=-0.591 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_FAIL=0.919, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id Wg3qeRwwLp4E for ; Wed, 23 May 2018 10:23:03 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id A41455F544 for ; Wed, 23 May 2018 10:23:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 77490E0160 for ; Wed, 23 May 2018 10:23:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 8E9912109F for ; Wed, 23 May 2018 10:23:00 +0000 (UTC) Date: Wed, 23 May 2018 10:23:00 +0000 (UTC) From: "Dmitry Katsubo (JIRA)" To: mime4j-dev@james.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (MIME4J-280) Exception stack trace should include the underlying parser exception MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MIME4J-280?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16487044#comment-16487044 ] Dmitry Katsubo commented on MIME4J-280: --------------------------------------- I will create a new pull request. However there are few more places in exception handling which would be nice to fix. This is about throwing {{ParseException}} without any message, for example in [{{Builder.java:120}}|https://github.com/apache/james-mime4j/blob/master/dom/src/main/java/org/apache/james/mime4j/field/address/Builder.java#L120] there is code like this: {code} if (n instanceof ASTphrase) { name = buildString((ASTphrase) n, false); } else { throw new ParseException(); // <-- can this me more informative? } {code} I suggest to replace such places with something more informative, e.g. {code} throw new ParseException("Address \"phrase\" is expected but got \"" + n + "\""); {code} Any idea to make it more informative? > Exception stack trace should include the underlying parser exception > -------------------------------------------------------------------- > > Key: MIME4J-280 > URL: https://issues.apache.org/jira/browse/MIME4J-280 > Project: James Mime4j > Issue Type: Improvement > Components: dom > Affects Versions: 0.7.2 > Reporter: Dmitry Katsubo > Priority: Trivial > > I think this is beneficial to be able to trace the exception back to JJTree parser, in particular I suggest to wrap {{TokenMgrError}} in corresponding places e.g. in the way it is shown in the following patch: > {code} > --- a/dom/src/main/jjtree/org/apache/james/mime4j/field/address/AddressListParser.jjt > +++ b/dom/src/main/jjtree/org/apache/james/mime4j/field/address/AddressListParser.jjt > @@ -77,7 +77,7 @@ > parseAddressList0(); > return (ASTaddress_list) jjtree.rootNode(); > } catch (TokenMgrError tme) { > - throw new ParseException(tme.getMessage()); > + throw new ParseException(tme); > } > } > > @@ -86,7 +86,7 @@ > parseAddress0(); > return (ASTaddress) jjtree.rootNode(); > } catch (TokenMgrError tme) { > - throw new ParseException(tme.getMessage()); > + throw new ParseException(tme); > } > } > > @@ -95,7 +95,7 @@ > parseMailbox0(); > return (ASTmailbox) jjtree.rootNode(); > } catch (TokenMgrError tme) { > - throw new ParseException(tme.getMessage()); > + throw new ParseException(tme); > } > } > > {code} > If the community finds it useful, I can contribute to that. -- This message was sent by Atlassian JIRA (v7.6.3#76005)