Do we have an EventException?
Brent Putman
putmanb at georgetown.edu
Wed Oct 28 21:36:40 EDT 2015
In one of the delegation actions, I found that I needed to return an
action event from way down in several nested method calls. What I came
up with was an EventException, which is just a vanilla RuntimeException
that also carries an event string. It can then be caught in for
example doExecute(...), to actually register the eventID in the
context. That avoids the need to figure out how to do it otherwise
when the various methods need to generally return other data, and don't
want to pollute the interfaces with event stuff, or returning booleans,
etc.
Do we already have something like this anywhere? I was thinking of
generalizing it, say to opensaml-profile-api. Thoughts?
/**
* Internal runtime exception class used to terminate processing
and communicate
* a failure event up the call stack to a common location for
production of the action event to
* be returned.
*/
private static class EventException extends RuntimeException {
/** Serial version UID. */
private static final long serialVersionUID = -9159689696046606020L;
/** The event ID. */
private final String eventID;
/**
* Constructor.
*
* @param event the event ID
* @param message the exception details message
* @param cause the exception cause
*/
public EventException(@Nonnull final String event, @Nullable
final String message,
@Nullable final Throwable cause) {
super(message, cause);
eventID =
Constraint.isNotNull(StringSupport.trimOrNull(event), "Event ID may not
be null");
}
/**
* Get the event represented by this exception.
*
* @return the event ID
*/
@Nonnull public String getEvent() {
return eventID;
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/dev/attachments/20151028/b48dfa9d/attachment.html>
More information about the dev
mailing list