Nov 15th, 2010, 04:33 PM
Error Handling in Declarative Webscripts?
When writing a declarative java webscript what is the preferred pattern for managing errors in the webscript?
For example if I have a webscript that fails (Runtime Exception) and throws a status 500
The rest of the page loads fine except for the place where the component should be I see a big fact stack trace.
In this case if this component fails the whole page should from a user point of view, fail as well and send the user to an "error page/system broken/SOL page.
I guess since the response is already committed there really isn't anything that can be done at this point besides made just hiding the stack trace
What can be done in regards to flow when a declarative webscript fails?
Nov 16th, 2010, 04:33 AM
Yes at the point a component webscript is rendered (declarative or java backed - it makes no difference if it's part of the page) then the response is already partially committed. The way to handle errors is to used the status template features of webscripts: http://wiki.alfresco.com/wiki/Web_Sc...esponse_Status
So for example, in Alfresco Share we have html.status.ftl file at the root of the components webscripts folder. In that we display a friendly-ish error message which is shown in place of the component.
Mar 22nd, 2011, 04:29 PM
html.status.ftl not working??
Great info in this post. This has helped!
We have a 500.html file in our src/main/webapp directory. This works to display a simple message (when a error occurs). When I try to replace this file with a html.status.ftl file, the page is not rendered. In fact, it appears the browser is getting no response. Chrome displays "Oops! This link appears to be broken." This happens even if I simply rename to working 500.html file to be html.status.ftl.
There is no corresponding error message in the catalina logs. Only the original offending error is present.
We are running Surf version 1.0.0-RC2.
The html.status.ftl file is attached. I had to zip it up because this forum does not allow upload of .ftl files?
Last edited by BoJo; Mar 23rd, 2011 at 12:12 PM.