[Helma-user] application-wide error action?

Chris Zumbrunn chris at zumbrunn.com
Thu Jun 14 18:52:09 CEST 2007


On Jun 10, 2007, at 1:03 , Aaron B. Iba wrote:

> Newbie question: is there a way to set an application-wide error
> action that will render all 404s, 500s, etc.?  I can't seem to find
> anything in the documentation.

You can handle errors by defining a notfound and/or error action.

Chris


 From http://adele.helma.org/download/helma/documentation/ 
documentation.html#GuideResponses

"Status 404 represents a 'Notfound'-response. Helma returns a 404 if  
there is no such defined action for a particular request. It is  
possible to catch such 404 by specifying a special notfound-action,  
which should be called as a fallback in such a case. This mechanism  
can be used to display a nicer formatted version of the 'Notfound'- 
response.

### Root/functions.js ###

function notfound_action() {
   res.write("Sorry, but nothing was found on this server.");
}
A request to http://localhost:8080/appname/foo will actually have the  
above notfound_action being called. It should be noted, that it is  
even possible to define separate notfound_actions for each prototype,  
and it is also possible to change the name of that fallback action  
via the property 'notfound' in app.properties.

In case that an error occurs during the processing of an action,  
Helma will catch that error and return a status code 200 with the  
error message contained as its response body. Similar to the notfound- 
action, it is also possible to define a special fallback action,  
which should be called in such a case. This is again useful for  
delivering a nicely rendered error message to the client, or  
alternatively to set the status code to some other value. That  
special function is named 'error_action', and can again be  
implemented for each prototype, and can be renamed by a property  
'error' in app.properties."









More information about the Helma-user mailing list