cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Russell <p...@luminas.co.uk>
Subject Re: handle-errors
Date Thu, 20 Jul 2000 12:21:49 GMT
On Thu, Jul 20, 2000 at 04:53:53AM -0700, Giacomo Pati wrote:
> [...]
> fragment. Now, how about making the now unique error handler a
> SitemapComponent which gets the Exception thrown and starts spitting
> SAX events to the pipeline as a special kind of Generator which renders
> the error to the user?
> Any comments?

Sounds good. We need to make sure that we don't loose an error
because of a problem with the secondary SAX stream (stylesheet
problems etc). We could handle that by copying an apacheism:

try {
	// Attempt to process the response.
	cocoon.process(req,res,out);
} catch ( Exception e ) {
	try {
	ErrorGenerator e = getComponent("generator:error");
	e.setException(e);
	e.setConsumer(/* err, something sitemap related here, I guess? */);
	e.generate()
	} catch ( Exception secondaryException ) {
		// resort to HTML
		PrintWriter pw = new PrintWriter(out);
		pw.println("<html>");
		pw.println("<head><title>Cocoon error</title></head>");
		pw.println("<body>");
		pw.println("<p>An error occoured processing " + req.getURI() +
			"<br />");
		e.printStackTrace(pw);
		pw.println("</p>");
		pw.println("<p>Additionally, the following error occoured");
		pw.println("whilst attempting to report the error:<br />");
		secondaryException.printStackTrace(pw);
		pw.println("</p>");
		
		pw.println("</body>");
	}
}

Excuse the dodgy Java etc, I've not got any of my API references
in front of me and my memory is more goldfish than elephant..
You get the idea, anyhow.

Cheers,


Paul

-- 
Paul Russell                               <paul@luminas.co.uk>
Technical Director,                   http://www.luminas.co.uk
Luminas Ltd.

Mime
View raw message