Blog post about T5 exception handling on GAE
FYI http://dmitrygusev.blogspot.com/2010/08/gae-and-tapestry5-exception-handling.html One thing I'd like T5 have though is something like in RemoteOnly mode in ASP.NET. http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx RemoteOnly Specifies that custom errors are shown only to the remote clients, and that ASP.NET errors are shown to the local host. This is the default value. So that even if I debug application in production mode I could get detailed exception report and not production one. Now I have to use development mode to debug (or consult with logs), but then I often forgetting to switch back to production mode prior to deploy. Can anybody share his practice of switching production mode on/off during development cycle? -- Dmitry Gusev AnjLab Team http://anjlab.com
RE: Blog post about T5 exception handling on GAE
Dmitry, From an example in an earlier post on this list, I use the approach of having: configuration.add(SymbolConstants.PRODUCTION_MODE, true); in my AppModule, so that by default production mode is always set to true for deployments, and then for any run/debug configurations in the developer's IDE, just override that setting with the VM argument: -Dtapestry.production-mode=false This means you will never need to set it for a release as the default is true. Hope this helps. Regards, Jim. -Original Message- From: Dmitry Gusev [mailto:dmitry.gu...@gmail.com] Sent: 27 August 2010 08:54 To: Tapestry users Subject: Blog post about T5 exception handling on GAE FYI http://dmitrygusev.blogspot.com/2010/08/gae-and-tapestry5-exception-handling .html One thing I'd like T5 have though is something like in RemoteOnly mode in ASP.NET. http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx RemoteOnly Specifies that custom errors are shown only to the remote clients, and that ASP.NET errors are shown to the local host. This is the default value. So that even if I debug application in production mode I could get detailed exception report and not production one. Now I have to use development mode to debug (or consult with logs), but then I often forgetting to switch back to production mode prior to deploy. Can anybody share his practice of switching production mode on/off during development cycle? -- Dmitry Gusev AnjLab Team http://anjlab.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Blog post about T5 exception handling on GAE
Thanks Jim, this might be a solution for most cases. There might be another issue though, what if I need to debug application behavior in production mode? In this mode some services may work different way. In this case there's no way to see detailed exception report on my development machine. But RemoteOnly behavior I noted before will be exactly what I wanted. On Fri, Aug 27, 2010 at 12:31, Jim O'Callaghan jc1000...@yahoo.co.ukwrote: Dmitry, From an example in an earlier post on this list, I use the approach of having: configuration.add(SymbolConstants.PRODUCTION_MODE, true); in my AppModule, so that by default production mode is always set to true for deployments, and then for any run/debug configurations in the developer's IDE, just override that setting with the VM argument: -Dtapestry.production-mode=false This means you will never need to set it for a release as the default is true. Hope this helps. Regards, Jim. -Original Message- From: Dmitry Gusev [mailto:dmitry.gu...@gmail.com] Sent: 27 August 2010 08:54 To: Tapestry users Subject: Blog post about T5 exception handling on GAE FYI http://dmitrygusev.blogspot.com/2010/08/gae-and-tapestry5-exception-handling .html One thing I'd like T5 have though is something like in RemoteOnly mode in ASP.NET. http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx RemoteOnly Specifies that custom errors are shown only to the remote clients, and that ASP.NET errors are shown to the local host. This is the default value. So that even if I debug application in production mode I could get detailed exception report and not production one. Now I have to use development mode to debug (or consult with logs), but then I often forgetting to switch back to production mode prior to deploy. Can anybody share his practice of switching production mode on/off during development cycle? -- Dmitry Gusev AnjLab Team http://anjlab.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Dmitry Gusev AnjLab Team http://anjlab.com
Re: Blog post about T5 exception handling on GAE
On Fri, 27 Aug 2010 08:50:16 -0300, Dmitry Gusev dmitry.gu...@gmail.com wrote: There might be another issue though, what if I need to debug application behavior in production mode? I can't think why you cannot debug the application in production mode in the same way you do in non-production mode. Debugging is a JVM matter, not a Tapestry one. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Blog post about T5 exception handling on GAE
Yes, I should say test. I didn't mean running java debugger. I mean trying to reproduce some test case using browser and getting exception page. On Fri, Aug 27, 2010 at 16:10, Thiago H. de Paula Figueiredo thiag...@gmail.com wrote: On Fri, 27 Aug 2010 08:50:16 -0300, Dmitry Gusev dmitry.gu...@gmail.com wrote: There might be another issue though, what if I need to debug application behavior in production mode? I can't think why you cannot debug the application in production mode in the same way you do in non-production mode. Debugging is a JVM matter, not a Tapestry one. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Dmitry Gusev AnjLab Team http://anjlab.com
Re: Blog post about T5 exception handling on GAE
On Fri, 27 Aug 2010 09:13:41 -0300, Dmitry Gusev dmitry.gu...@gmail.com wrote: Yes, I should say test. I didn't mean running java debugger. I mean trying to reproduce some test case using browser and getting exception page. You can override the error page (which I recommend, anyway), use the logic you want for showing or not the stack trace and use the ExceptionDisplay component to show the exception. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Blog post about T5 exception handling on GAE
Have you looked at the link I've posted in my first message? :) I know I can override the error page. But I like the default one. I just don't like its default behavior which only relies on PRODUCTION_MODE symbol. What I suggest is to change this behavior and analyze if the user that get this exception is a local user. And if its a local user show him error page just like it was in non-production mode. This is what RemoteOnly mode means in ASP.NET. On Fri, Aug 27, 2010 at 16:19, Thiago H. de Paula Figueiredo thiag...@gmail.com wrote: On Fri, 27 Aug 2010 09:13:41 -0300, Dmitry Gusev dmitry.gu...@gmail.com wrote: Yes, I should say test. I didn't mean running java debugger. I mean trying to reproduce some test case using browser and getting exception page. You can override the error page (which I recommend, anyway), use the logic you want for showing or not the stack trace and use the ExceptionDisplay component to show the exception. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Dmitry Gusev AnjLab Team http://anjlab.com
Re: T5: Exception Handling
into a pipeline. Can you show me some code of how to do this? Leon Peter Stavrinides wrote: Hi Leon I posted a number of questions to the list about this topic, but got only a few perls. One of them was this post, particularly Filip's answer: http://www.mail-archive.com/users@tapestry.apache.org/msg21914.html Also see this page, for how to override Tapestry's error page with your own friendly error page: http://wiki.apache.org/tapestry/Tapestry5ExceptionPage I am not sure what you are trying to do, but would suggest you familiarize yourself a bit more with Tapestry's error reporting mechanisms, which imho are incredibly powerful and easy to use. Hope this helps, Peter - Original Message - From: Leon Derks [EMAIL PROTECTED] To: Tapestry users users@tapestry.apache.org Sent: Friday, 16 May, 2008 1:35:19 PM GMT +02:00 Athens, Beirut, Bucharest, Istanbul Subject: T5: Exception Handling Hello What is the best way to handle exceptions in Tapestry 5? I want to show some kind of general error page, when an exception occurs. At the moment I have a onException method in my BasePage class. But for some reason the Error page is not returned. What is the way in T5 to handle exceptions? Object onException(Throwable cause) { return new Error(); } Leon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Exception Handling
Hi Filip, Thanks for your answer. I understand now. But one final question. How does your redirectService looks like? Leon Filip S. Adamsen wrote: Hi Leon, How to override server error pages depends on what server you're using. As far as I'm aware it's unfortunately not possible to use Tapestry pages as server error pages - if I'm wrong here, I'd really like to know how to do it. :) What I mean by turning the RequestExceptionHandler into a pipeline is that I've overridden the original service with my own that uses a pipeline. http://tapestry.apache.org/tapestry5/tapestry-ioc/pipeline.html So I define my filter: public interface RequestExceptionFilter { void handleRequestException(Throwable exception, RequestExceptionHandler handler) throws IOException; } Then I create a new RequestExceptionHandler as a pipeline: public static RequestExceptionHandler buildImprovedRequestExceptionHandler( ListRequestExceptionFilter configuration, @InjectService(RequestExceptionHandler) RequestExceptionHandler requestExceptionHandler, PipelineBuilder builder, Logger logger ) { return builder.build( logger, RequestExceptionHandler.class, RequestExceptionFilter.class, configuration, requestExceptionHandler ); } I then contribute this to AliasOverrides to replace the default RequestExceptionHandler: public static void contributeAliasOverrides( ConfigurationAliasContribution configuration, @InjectService(ImprovedRequestExceptionHandler) RequestExceptionHandler requestExceptionHandler ) { configuration.add(AliasContribution.create(RequestExceptionHandler.class, requestExceptionHandler)); } I can then contribute filters to the pipeline like this: public static void contributeImprovedRequestExceptionHandler( OrderedConfigurationRequestExceptionFilter configuration, RequestExceptionErrorFilter requestExceptionErrorFilter ) { configuration.add(Error, requestExceptionErrorFilter); } Where RequestExceptionErrorFilter looks like this: public class RequestExceptionErrorFilter implements RequestExceptionFilter { private final RedirectService redirectService; private final SecurityService securityService; private final Logger logger; public RequestExceptionErrorFilter(RedirectService redirectService, SecurityService securityService, Logger logger) { this.redirectService = redirectService; this.securityService = securityService; this.logger = logger; } public void handleRequestException(Throwable exception, RequestExceptionHandler handler) throws IOException { if (securityService.isProductionModeEnabled()) { logger.error(Exception during request, exception); redirectService.sendRedirect(ErrorIndex.class, false); } else { handler.handleRequestException(exception); } } } RedirectService and SecurityService are my own classes. They just make some things easier for me. As you can see I show an error page when I'm in production but invoke the next filter in the pipeline if I'm not. You could contribute more filters if needed. I've been wanting to contribute a strategy filter before this one allowing to do different things depending on the type of exception thrown, but haven't had the time nor need to do so yet. http://tapestry.apache.org/tapestry5/tapestry-ioc/strategy.html Anyhow, hope this helps - if not, you know where to ask. :) -Filip On 2008-05-16 17:37, Leon Derks wrote: Thanks Peter, Your original question in the post is also what I would like to know. Do you now know how to override server error pages(404, 505 etc)? And I don't understand what Flip means with :I've turned the RequestExceptionHandler service into a pipeline. Can you show me some code of how to do this? Leon Peter Stavrinides wrote: Hi Leon I posted a number of questions to the list about this topic, but got only a few perls. One of them was this post, particularly Filip's answer: http://www.mail-archive.com/users@tapestry.apache.org/msg21914.html Also see this page, for how to override Tapestry's error page with your own friendly error page: http://wiki.apache.org/tapestry/Tapestry5ExceptionPage I am not sure what you are trying to do, but would suggest you familiarize yourself a bit more with Tapestry's error reporting mechanisms, which imho are incredibly powerful and easy to use. Hope this helps, Peter - Original Message - From: Leon Derks [EMAIL PROTECTED] To: Tapestry users users@tapestry.apache.org Sent: Friday, 16 May, 2008 1:35:19 PM GMT +02:00 Athens, Beirut, Bucharest, Istanbul Subject: T5: Exception Handling Hello What is the best way to handle exceptions in Tapestry 5? I want to show some kind of general error page, when an exception occurs. At the moment I have a onException method in my BasePage class. But for some
Re: T5: Exception Handling
Just a little side note: Filip is right, you can't use a Tapestry page for these, but that is probably the correct behavior as this is a different type of error (an exception to the rule if you like) which the server needs to handle by explicitly interrupting a request/response and generating a new one on the server in accordance with the error condition... For example a page not found has little to do with your Tapestry application, but the server is still being addressed and needs to respond. So you wouldn't want a Tapestry to handle these IMHO, but that doesn't stop tapestry apps from making use of them when required! (using response.sendError) To configure: You would simply use a standard JSP / HTML error page, and wire it in your web.xml. I am using Tomcat and it works great... works on Jetty too. The only error page/s I can't get to override perfectly are 401 and 503, but I have found some workarounds for these. 503 is a service unavailable/ under maintenance error and will occur when the server is running but the application is not, so wouldn't make sense using it in your app anyhow. I found Tomcat is a little deficient here, see: http://www.nabble.com/Error-Page-Question-td16153138.html (if anyone has solved this please share).For the 401 authentication error, I simply use a 403 forbidden instead, but I can get away with this as I am using forms authentication. I had thought about putting some of this stuff on the wiki... as yet I haven't because error handling can be very scenario specific. Anyway here is a short example of how to configure your server error page: Add to web.xml: error-page error-code404/error-code location/error404.jsp/location /error-page error404.jsp: (Important - create this file in /webapp) and NOT in /webapp/WEB-INF %@ page isErrorPage=true % html xmlns:t=http://tapestry.apache.org/schema/tapestry_5_0_0.xsd; head titleError 404 Page Not Found/title /head body h1Page Not Found/h1br/br/ div We apologise for any inconvenience, but the resource you have specified cannot be found, please check the URL is typed correctly. br/br/ If you require assistance please contact client support. To continue a href=JavaScript:history.go(-1)return to the previous page/a.br/br/ /div /body /html As simple as that... Cheers, Peter. - Original Message - From: Filip S. Adamsen [EMAIL PROTECTED] To: Tapestry users users@tapestry.apache.org Sent: Sunday, 18 May, 2008 1:39:31 AM GMT +02:00 Athens, Beirut, Bucharest, Istanbul Subject: Re: T5: Exception Handling Hi Leon, How to override server error pages depends on what server you're using. As far as I'm aware it's unfortunately not possible to use Tapestry pages as server error pages - if I'm wrong here, I'd really like to know how to do it. :) What I mean by turning the RequestExceptionHandler into a pipeline is that I've overridden the original service with my own that uses a pipeline. http://tapestry.apache.org/tapestry5/tapestry-ioc/pipeline.html So I define my filter: public interface RequestExceptionFilter { void handleRequestException(Throwable exception, RequestExceptionHandler handler) throws IOException; } Then I create a new RequestExceptionHandler as a pipeline: public static RequestExceptionHandler buildImprovedRequestExceptionHandler( ListRequestExceptionFilter configuration, @InjectService(RequestExceptionHandler) RequestExceptionHandler requestExceptionHandler, PipelineBuilder builder, Logger logger ) { return builder.build( logger, RequestExceptionHandler.class, RequestExceptionFilter.class, configuration, requestExceptionHandler ); } I then contribute this to AliasOverrides to replace the default RequestExceptionHandler: public static void contributeAliasOverrides( ConfigurationAliasContribution configuration, @InjectService(ImprovedRequestExceptionHandler) RequestExceptionHandler requestExceptionHandler ) { configuration.add(AliasContribution.create(RequestExceptionHandler.class, requestExceptionHandler)); } I can then contribute filters to the pipeline like this: public static void contributeImprovedRequestExceptionHandler( OrderedConfigurationRequestExceptionFilter configuration, RequestExceptionErrorFilter requestExceptionErrorFilter ) { configuration.add(Error, requestExceptionErrorFilter); } Where RequestExceptionErrorFilter looks like this: public class RequestExceptionErrorFilter implements RequestExceptionFilter { private final RedirectService redirectService; private final SecurityService securityService; private final Logger logger; public RequestExceptionErrorFilter(RedirectService redirectService, SecurityService securityService, Logger logger) { this.redirectService = redirectService
Re: T5: Exception Handling
On 5/19/08, Peter Stavrinides [EMAIL PROTECTED] wrote: To configure: You would simply use a standard JSP / HTML error page, and wire it in your web.xml. I am using Tomcat and it works great... works on Jetty too. Something I've done once is to setup a 404.html page that redirects to a Tapestry page via Javascript, including the original URL so I can log it. ;) -- Thiago - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Exception Handling
understand what Flip means with :I've turned the RequestExceptionHandler service into a pipeline. Can you show me some code of how to do this? Leon Peter Stavrinides wrote: Hi Leon I posted a number of questions to the list about this topic, but got only a few perls. One of them was this post, particularly Filip's answer: http://www.mail-archive.com/users@tapestry.apache.org/msg21914.html Also see this page, for how to override Tapestry's error page with your own friendly error page: http://wiki.apache.org/tapestry/Tapestry5ExceptionPage I am not sure what you are trying to do, but would suggest you familiarize yourself a bit more with Tapestry's error reporting mechanisms, which imho are incredibly powerful and easy to use. Hope this helps, Peter - Original Message - From: Leon Derks [EMAIL PROTECTED] To: Tapestry users users@tapestry.apache.org Sent: Friday, 16 May, 2008 1:35:19 PM GMT +02:00 Athens, Beirut, Bucharest, Istanbul Subject: T5: Exception Handling Hello What is the best way to handle exceptions in Tapestry 5? I want to show some kind of general error page, when an exception occurs. At the moment I have a onException method in my BasePage class. But for some reason the Error page is not returned. What is the way in T5 to handle exceptions? Object onException(Throwable cause) { return new Error(); } Leon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Exception Handling
Now why hadn't I thought of that... :D Thanks! -Filip Thiago HP skrev: On 5/19/08, Peter Stavrinides [EMAIL PROTECTED] wrote: To configure: You would simply use a standard JSP / HTML error page, and wire it in your web.xml. I am using Tomcat and it works great... works on Jetty too. Something I've done once is to setup a 404.html page that redirects to a Tapestry page via Javascript, including the original URL so I can log it. ;) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Exception Handling
On 5/19/08, Filip S. Adamsen [EMAIL PROTECTED] wrote: Now why hadn't I thought of that... :D Sometimes, a solution is so simple that we unconciously search for more complicated ones . . . :) Thanks! You're welcome! -- Thiago - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Exception Handling
Given that a JSP is basically a servlet, why not do something like % response.include(request.getContextPath() + /MyTapestryErrorPage); % from your jsp exception page btw I can't remember - can you map an exception handler to a servlet in web.xml? Toby - Original Message From: Thiago HP [EMAIL PROTECTED] To: Tapestry users users@tapestry.apache.org Sent: Monday, 19 May, 2008 2:52:02 PM Subject: Re: T5: Exception Handling On 5/19/08, Peter Stavrinides [EMAIL PROTECTED] wrote: To configure: You would simply use a standard JSP / HTML error page, and wire it in your web.xml. I am using Tomcat and it works great... works on Jetty too. Something I've done once is to setup a 404.html page that redirects to a Tapestry page via Javascript, including the original URL so I can log it. ;) -- Thiago - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Exception Handling
Directly adding a tapestry url also works error-page error-code404/error-code location/NotFound.html/location /error-page That was in T4 that used the servlet (instead of filter) approach... perhaps it also works in T5. On Mon, May 19, 2008 at 5:35 PM, Toby Hobson [EMAIL PROTECTED] wrote: Given that a JSP is basically a servlet, why not do something like % response.include(request.getContextPath() + /MyTapestryErrorPage); % from your jsp exception page btw I can't remember - can you map an exception handler to a servlet in web.xml? Toby - Original Message From: Thiago HP [EMAIL PROTECTED] To: Tapestry users users@tapestry.apache.org Sent: Monday, 19 May, 2008 2:52:02 PM Subject: Re: T5: Exception Handling On 5/19/08, Peter Stavrinides [EMAIL PROTECTED] wrote: To configure: You would simply use a standard JSP / HTML error page, and wire it in your web.xml. I am using Tomcat and it works great... works on Jetty too. Something I've done once is to setup a 404.html page that redirects to a Tapestry page via Javascript, including the original URL so I can log it. ;) -- Thiago - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Exception Handling
Hi Leon, How to override server error pages depends on what server you're using. As far as I'm aware it's unfortunately not possible to use Tapestry pages as server error pages - if I'm wrong here, I'd really like to know how to do it. :) What I mean by turning the RequestExceptionHandler into a pipeline is that I've overridden the original service with my own that uses a pipeline. http://tapestry.apache.org/tapestry5/tapestry-ioc/pipeline.html So I define my filter: public interface RequestExceptionFilter { void handleRequestException(Throwable exception, RequestExceptionHandler handler) throws IOException; } Then I create a new RequestExceptionHandler as a pipeline: public static RequestExceptionHandler buildImprovedRequestExceptionHandler( ListRequestExceptionFilter configuration, @InjectService(RequestExceptionHandler) RequestExceptionHandler requestExceptionHandler, PipelineBuilder builder, Logger logger ) { return builder.build( logger, RequestExceptionHandler.class, RequestExceptionFilter.class, configuration, requestExceptionHandler ); } I then contribute this to AliasOverrides to replace the default RequestExceptionHandler: public static void contributeAliasOverrides( ConfigurationAliasContribution configuration, @InjectService(ImprovedRequestExceptionHandler) RequestExceptionHandler requestExceptionHandler ) { configuration.add(AliasContribution.create(RequestExceptionHandler.class, requestExceptionHandler)); } I can then contribute filters to the pipeline like this: public static void contributeImprovedRequestExceptionHandler( OrderedConfigurationRequestExceptionFilter configuration, RequestExceptionErrorFilter requestExceptionErrorFilter ) { configuration.add(Error, requestExceptionErrorFilter); } Where RequestExceptionErrorFilter looks like this: public class RequestExceptionErrorFilter implements RequestExceptionFilter { private final RedirectService redirectService; private final SecurityService securityService; private final Logger logger; public RequestExceptionErrorFilter(RedirectService redirectService, SecurityService securityService, Logger logger) { this.redirectService = redirectService; this.securityService = securityService; this.logger = logger; } public void handleRequestException(Throwable exception, RequestExceptionHandler handler) throws IOException { if (securityService.isProductionModeEnabled()) { logger.error(Exception during request, exception); redirectService.sendRedirect(ErrorIndex.class, false); } else { handler.handleRequestException(exception); } } } RedirectService and SecurityService are my own classes. They just make some things easier for me. As you can see I show an error page when I'm in production but invoke the next filter in the pipeline if I'm not. You could contribute more filters if needed. I've been wanting to contribute a strategy filter before this one allowing to do different things depending on the type of exception thrown, but haven't had the time nor need to do so yet. http://tapestry.apache.org/tapestry5/tapestry-ioc/strategy.html Anyhow, hope this helps - if not, you know where to ask. :) -Filip On 2008-05-16 17:37, Leon Derks wrote: Thanks Peter, Your original question in the post is also what I would like to know. Do you now know how to override server error pages(404, 505 etc)? And I don't understand what Flip means with :I've turned the RequestExceptionHandler service into a pipeline. Can you show me some code of how to do this? Leon Peter Stavrinides wrote: Hi Leon I posted a number of questions to the list about this topic, but got only a few perls. One of them was this post, particularly Filip's answer: http://www.mail-archive.com/users@tapestry.apache.org/msg21914.html Also see this page, for how to override Tapestry's error page with your own friendly error page: http://wiki.apache.org/tapestry/Tapestry5ExceptionPage I am not sure what you are trying to do, but would suggest you familiarize yourself a bit more with Tapestry's error reporting mechanisms, which imho are incredibly powerful and easy to use. Hope this helps, Peter - Original Message - From: Leon Derks [EMAIL PROTECTED] To: Tapestry users users@tapestry.apache.org Sent: Friday, 16 May, 2008 1:35:19 PM GMT +02:00 Athens, Beirut, Bucharest, Istanbul Subject: T5: Exception Handling Hello What is the best way to handle exceptions in Tapestry 5? I want to show some kind of general error page, when an exception occurs. At the moment I have a onException method in my BasePage class. But for some reason the Error page is not returned. What is the way in T5 to handle exceptions? Object onException(Throwable cause) { return new Error
T5: Exception Handling
Hello What is the best way to handle exceptions in Tapestry 5? I want to show some kind of general error page, when an exception occurs. At the moment I have a onException method in my BasePage class. But for some reason the Error page is not returned. What is the way in T5 to handle exceptions? Object onException(Throwable cause) { return new Error(); } Leon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Exception Handling
Hi Leon I posted a number of questions to the list about this topic, but got only a few perls. One of them was this post, particularly Filip's answer: http://www.mail-archive.com/users@tapestry.apache.org/msg21914.html Also see this page, for how to override Tapestry's error page with your own friendly error page: http://wiki.apache.org/tapestry/Tapestry5ExceptionPage I am not sure what you are trying to do, but would suggest you familiarize yourself a bit more with Tapestry's error reporting mechanisms, which imho are incredibly powerful and easy to use. Hope this helps, Peter - Original Message - From: Leon Derks [EMAIL PROTECTED] To: Tapestry users users@tapestry.apache.org Sent: Friday, 16 May, 2008 1:35:19 PM GMT +02:00 Athens, Beirut, Bucharest, Istanbul Subject: T5: Exception Handling Hello What is the best way to handle exceptions in Tapestry 5? I want to show some kind of general error page, when an exception occurs. At the moment I have a onException method in my BasePage class. But for some reason the Error page is not returned. What is the way in T5 to handle exceptions? Object onException(Throwable cause) { return new Error(); } Leon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Exception Handling
Thanks Peter, Your original question in the post is also what I would like to know. Do you now know how to override server error pages(404, 505 etc)? And I don't understand what Flip means with :I've turned the RequestExceptionHandler service into a pipeline. Can you show me some code of how to do this? Leon Peter Stavrinides wrote: Hi Leon I posted a number of questions to the list about this topic, but got only a few perls. One of them was this post, particularly Filip's answer: http://www.mail-archive.com/users@tapestry.apache.org/msg21914.html Also see this page, for how to override Tapestry's error page with your own friendly error page: http://wiki.apache.org/tapestry/Tapestry5ExceptionPage I am not sure what you are trying to do, but would suggest you familiarize yourself a bit more with Tapestry's error reporting mechanisms, which imho are incredibly powerful and easy to use. Hope this helps, Peter - Original Message - From: Leon Derks [EMAIL PROTECTED] To: Tapestry users users@tapestry.apache.org Sent: Friday, 16 May, 2008 1:35:19 PM GMT +02:00 Athens, Beirut, Bucharest, Istanbul Subject: T5: Exception Handling Hello What is the best way to handle exceptions in Tapestry 5? I want to show some kind of general error page, when an exception occurs. At the moment I have a onException method in my BasePage class. But for some reason the Error page is not returned. What is the way in T5 to handle exceptions? Object onException(Throwable cause) { return new Error(); } Leon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]