cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lars Huttar" <>
Subject how to throw (not propagate) an error?
Date Tue, 30 Dec 2003 20:50:41 GMT
Hi all,
I'm working on an application that uses user authentication/authorization.
Rather than using the Authentication Framework,
I'm handling auth/auth myself in the sitemap.

When a request is processed, the pipeline that matches the
request calls the authorization pipeline. The authorization
pipeline returns the requested data if the user is logged in
and authorized; otherwise, it returns data indicating an
authorization failure.

Problem: every pipeline that calls the authorization pipeline
has to know how to handle the two possible types of returned
data, and respond accordingly. The authorization pipeline
might even be called two or three levels deep in the call stack,
and all intervening pipelines have to know about the possible
failure condition and how to handle it.

This is a classic case where error handling helps: the authorization
pipeline should be able to throw an error condition, which is
caught by an error handler <map:handle-errors>, and none of
the other code needs to be able to handle error data instead of
the usual data.

But my problem is, how to throw my own error?
I see there is a "notify" generator,
so I can invoke
  <map:generate type="notifying" />
somehow in my authorization pipeline when auth fails;
but how do I control what kind of error is generated?
And anyway, the documentation says this generator can only
be used within a <handle-errors> section, i.e. you can't
throw an error with it until an error condition already exists.

So to throw my own error, do I have to create an XSP page with
Java code in it to throw an error? If so could someone
give me an example?
Or is there some kind of error-throwing instruction for the sitemap?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message