public boolean invokeErrorHandler(ProcessingNode node, Exception ex, Environment env)
throws Exception {
Map objectModel = env.getObjectModel();
InvokeContext errorContext = null;
boolean nodeSuccesfull = false;
try {
if (objectModel.get(Constants.NOTIFYING_OBJECT) == null) {
// error has not been processed by another handler before
// Try to reset the response to avoid mixing already produced output
// and error page.
env.tryResetResponse();
// Create a Notifying
NotifyingBuilder notifyingBuilder= (NotifyingBuilder)this.manager.lookup(NotifyingBuilder.ROLE);
Notifying currentNotifying = null;
try {
currentNotifying = notifyingBuilder.build(this, ex);
} finally {
this.manager.release(notifyingBuilder);
}
// Add it to the object model
objectModel.put(Constants.NOTIFYING_OBJECT, currentNotifying);
// Also add the exception
objectModel.put(ObjectModelHelper.THROWABLE_OBJECT, ex);
}
// Build a new context
errorContext = new InvokeContext();
errorContext.enableLogging(getLogger());
errorContext.compose(this.manager);
nodeSuccesfull = node.invoke(env, errorContext);
} catch (Exception subEx) {
getLogger().error("An exception occured in while handling errors at " + node.getLocation(), subEx);
// Rethrow it : it will either be handled by the parent sitemap or by the environment (e.g. Cocoon servlet)
throw subEx;
} finally {
if (errorContext != null) {
errorContext.dispose();
}
}
if (nodeSuccesfull) {
return true;