Return-Path: Delivered-To: apmail-click-dev-archive@www.apache.org Received: (qmail 68455 invoked from network); 7 Mar 2010 11:46:01 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 Mar 2010 11:46:01 -0000 Received: (qmail 13751 invoked by uid 500); 7 Mar 2010 11:45:41 -0000 Delivered-To: apmail-click-dev-archive@click.apache.org Received: (qmail 13733 invoked by uid 500); 7 Mar 2010 11:45:41 -0000 Mailing-List: contact dev-help@click.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@click.apache.org Delivered-To: mailing list dev@click.apache.org Received: (qmail 13726 invoked by uid 99); 7 Mar 2010 11:45:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Mar 2010 11:45:41 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_FRT_CLICK,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sabob1@gmail.com designates 209.85.222.195 as permitted sender) Received: from [209.85.222.195] (HELO mail-pz0-f195.google.com) (209.85.222.195) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Mar 2010 11:45:40 +0000 Received: by pzk33 with SMTP id 33so281539pzk.5 for ; Sun, 07 Mar 2010 03:45:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=KYnRkOiplac42rBcQ006lFPJ5X34+E9SXztqNE0dE4U=; b=athPux1J9VMzdHgIlcfenR6JEUlLWhSKuABW6Ef0s0LudwjqMwPGipMaV7zK10F6fb J8uoe9mXMDMBKTETaNznBua0nFweqxQ/HMSSvzk4Zp/xztauuR7gi4feCsighjGusvlW yo5U1ykgafBuR5jbxFxxwu3VKmTEjtye17UHQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=Fag+JXseEFuGyS90TRjrBvnfgrxHZQHypICk7WOUsjMgFRttPtE5WdW9JTAu1c0kTW pEu7kr6uIVNyn4AbNubtvA76G97lZdL05OXUQ2dMqpjt0y94zI+ji97sgKf8Hov9F4FZ 89T+b2HhrSKeOgz1PuQLTB1ON5/qQisHjZPG8= Received: by 10.141.214.8 with SMTP id r8mr2180846rvq.268.1267962319765; Sun, 07 Mar 2010 03:45:19 -0800 (PST) Received: from [10.1.1.3] ([124.171.57.39]) by mx.google.com with ESMTPS id 23sm3596885pzk.14.2010.03.07.03.45.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 07 Mar 2010 03:45:18 -0800 (PST) Message-ID: <4B9391CA.1070708@gmail.com> Date: Sun, 07 Mar 2010 22:45:14 +1100 From: Bob Schellink User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: dev@click.apache.org Subject: Re: Fwd: svn commit: r919953 - in /click/trunk/click/framework/src/org/apache/click/service: TemplateService.java VelocityTemplateService.java References: <20100307093352.70FF323889E1@eris.apache.org> <525d8e11003070332t68e1970dt226d3783c7fd4ae@mail.gmail.com> In-Reply-To: <525d8e11003070332t68e1970dt226d3783c7fd4ae@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi Malcolm, If the template threw a normal Exception the error was wrapped in a TemplateException and passed to ErrorReport. Inside ErrorReport a check is made if the error is a TemplateException. If it is, a check is made if the TemplateName is set nor not. If the TemplateName is *not* set, as will be the case of a NPE, very little diagnostics is given. So I reverted TemplateService to throw a normal exception instead of wrapping it in a TE. This way the other code path is followed when diagnostics is provided for the Exception. Another way we could resolve it is to provide the templatePath when a normal Exception is thrown? kind regards bob On 7/03/2010 10:32 PM, Malcolm Edgar wrote: > Hi Bob, > > What was the exception issue caused by this refactoring? > > regards Malcolm Edgar > > ---------- Forwarded message ---------- > From: > Date: Sun, Mar 7, 2010 at 8:33 PM > Subject: svn commit: r919953 - in > /click/trunk/click/framework/src/org/apache/click/service: > TemplateService.java VelocityTemplateService.java > To: commits@click.apache.org > > > Author: sabob > Date: Sun Mar 7 09:33:51 2010 > New Revision: 919953 > > URL: http://svn.apache.org/viewvc?rev=919953&view=rev > Log: > fixed exception handling caused by CLK-606 refactoring > > Modified: > click/trunk/click/framework/src/org/apache/click/service/TemplateService.java > click/trunk/click/framework/src/org/apache/click/service/VelocityTemplateService.java > > Modified: click/trunk/click/framework/src/org/apache/click/service/TemplateService.java > URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/service/TemplateService.java?rev=919953&r1=919952&r2=919953&view=diff > ============================================================================== > --- click/trunk/click/framework/src/org/apache/click/service/TemplateService.java > (original) > +++ click/trunk/click/framework/src/org/apache/click/service/TemplateService.java > Sun Mar 7 09:33:51 2010 > @@ -76,7 +76,7 @@ > * @throws TemplateException if template error occurs > */ > public void renderTemplate(Page page, Map model, > Writer writer) > - throws IOException, TemplateException; > + throws TemplateException, Exception; > > /** > * Render the given template and model to the writer. > @@ -88,6 +88,6 @@ > * @throws TemplateException if template error occurs > */ > public void renderTemplate(String templatePath, Map Object> model, Writer writer) > - throws IOException, TemplateException; > + throws TemplateException, Exception; > > } > > Modified: click/trunk/click/framework/src/org/apache/click/service/VelocityTemplateService.java > URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/service/VelocityTemplateService.java?rev=919953&r1=919952&r2=919953&view=diff > ============================================================================== > --- click/trunk/click/framework/src/org/apache/click/service/VelocityTemplateService.java > (original) > +++ click/trunk/click/framework/src/org/apache/click/service/VelocityTemplateService.java > Sun Mar 7 09:33:51 2010 > @@ -31,6 +31,7 @@ > import javax.servlet.ServletContext; > > import org.apache.click.Page; > +import org.apache.click.Context; > import org.apache.click.util.ClickUtils; > import org.apache.click.util.ErrorReport; > import org.apache.commons.lang.Validate; > @@ -315,7 +316,7 @@ > * @throws TemplateException if template error occurs > */ > public void renderTemplate(Page page, Map model, > Writer writer) > - throws IOException, TemplateException { > + throws TemplateException, Exception { > > String templatePath = page.getTemplate(); > > @@ -338,7 +339,7 @@ > * @throws Exception if an error occurs > */ > public void renderTemplate(String templatePath, Map Object> model, Writer writer) > - throws IOException, TemplateException { > + throws TemplateException, Exception { > > internalRenderTemplate(templatePath, null, model, writer); > } > @@ -506,7 +507,7 @@ > Page page, > Map model, > Writer writer) > - throws IOException, TemplateException { > + throws TemplateException, Exception { > > final VelocityContext velocityContext = new VelocityContext(model); > > @@ -534,9 +535,6 @@ > > template.merge(velocityContext, velocityWriter); > > - } catch (IOException ioe) { > - throw ioe; > - > } catch (ParseErrorException pee) { > TemplateException te = new TemplateException(pee, > pee.getTemplateName(), > @@ -615,16 +613,23 @@ > throw te; > > } catch (Exception error) { > - TemplateException te = new TemplateException(error); > > // Exception occurred merging template and model. It is possible > // that some output has already been written, so we will append the > // error report to the previous output. > + > + Context context = null; > + if (page == null) { > + context = Context.getThreadLocalContext(); > + } else { > + context = page.getContext(); > + } > + > ErrorReport errorReport = > - new ErrorReport(te, > + new ErrorReport(error, > ((page != null) ? page.getClass() : null), > configService.isProductionMode(), > - page.getContext().getRequest(), > + context.getRequest(), > configService.getServletContext()); > > if (velocityWriter == null) { > @@ -634,7 +639,7 @@ > > velocityWriter.write(errorReport.toString()); > > - throw te; > + throw error; > > } finally { > if (velocityWriter != null) { >