Target: Class annotated with @StageDefinition or an attribute of a POJO annotated with @StageDefinition.

Description: Declares the current stage as the stage that will manage all raised exceptions defined in the exceptions parameter.
With this definition, DiF will automatically redirect the application execution flow to this page, whenever and wherever any exception that is an instance of any of the exception classes given.

JavaDoc: Click here


Name Description Data type Required Default value
exceptions Comma-separated list of the FQNs of the handled exceptions. String No java.lang.Exception


@StageDefinition(name = "Database Error Stage", service = "errorhandlingservice")
@ExceptionHandler(exceptions = "org.hibernate.HibernateException")
@View(target = "internal/databaseError.jsp")
@DispatcherMode(authenticate = false, authorize = false)
public class HibernateErrorStage extends AbstractErrorHandler {

    public String getMessageContent()
        Exception exception = (Exception) context.getRequest().getAttribute(
        HibernateException exception = getExceptionWithinStack(HibernateException.class, exception);
        if (exception == null)
            return "No Hibernate message found!";
            return exception.getMessage();

You can see the optional usage of the DiF provided AbstractErrorHandler, that provides the getExceptionWithinStack method for crawling inside the exception stack and returning the handled exception that triggered this handler.

See also:

Back to annotation reference