Documentation Archive Developer
Search
PATH  Documentation > WebObjects 4.5 > WebObjects Developer's Guide


Table of Contents Previous Section

Error Handling

When an error occurs, WebObjects by default returns a page containing debugging information and displays that page in the Web browser. This information is useful when you're in the debugging phase, but when you're ready to deploy, you probably want to make sure that your users don't see such information.

The WOApplication class provides the following methods that you can override to show your own error page.

Method Invoked When
handleSessionCreationErrorInContext: The application needs to create a new session but can't.
handleSessionRestorationErrorInContext: The application receives a request from a session that has timed out.
handlePageRestorationErrorInContext: The application tries to access an existing page but cannot. Usually, this occurs when the user has backtracked beyond the limit set by setPageCacheSize: and setPageRefreshOnBacktrackEnabled: is NO.
handleException:inContext: (handleException in Java) The application receives an exception; that is, any general type of error has occurred.

For example, the following implementation of handleException:inContext: returns a component named ErrorPage whenever an error occurs in the application.

public WOResponse handleException(java.lang.Throwable 
anException, WOContext aContext) {
WOResponse response = aContext.component().
pageWithName("ErrorPage").generateResponse();

return response;
}
Notice that this method, and all of the error-handling methods, return a WOResponse object instead of a WOComponent object.

Table of Contents Next Section