Mostrando entradas con la etiqueta seam exceptions. Mostrar todas las entradas
Mostrando entradas con la etiqueta seam exceptions. Mostrar todas las entradas

17 marzo 2010

Unified error page and exception handling

Unified error page and exception handling


A web application can run into a server-side error for many different reasons and at any point in time. Finding the right strategy for your application, how to deal with these error conditions and exceptional situations, can be difficult. This page provides some guidelines and a simple but effective solution.

When a client request is handled by a web application server, exceptions can be thrown by code at any time. Typically, you need to consider:

  • Exceptions thrown by the web application server, usually the servlet container. For example, exceptions you definitely have to expect and handle include session limit violations. If your servlet container reaches its configured maximum active session limit, your users should be presented with a nice error message that tells them to come back later.
  • Exceptions can be thrown by the web application frameworks and 3rd party libraries you are using. In a Seam application, those frameworks would typically include JSF, Facelets, Hibernate, and of course Seam and any of its integration modules. There are many exceptions that are obvioulsy related to bugs in your application, for these you might want to encourage the users to report these with a nice message. But you also have other exceptions, such as database lock acquisition failures, that indicate an overloaded system, which does not necessarily require a bug report.
  • Finally, you have your own error handling in your web application. You use (runtime) infrastructure exceptions to indicate fatal error conditions which should be reported by users when they encounter them. You use (checked) application exceptions that are expected and are handled in your code, probably without even letting the users know that some exceptional application flow occurred behind the scenes.

Handling recoverable exceptions

Seam comes with an exception handling servlet filter that wraps its processing of a request:

(... seguir leyendo en el sitio original)

16 marzo 2010

hermes: exceptions

Enabling Seam exception handling

mirar seam_reference: 6.12.2. Enabling Seam exception handling

You need to disable Facelets development mode in web.xml and Seam debug mode in
components.xml if you want your exception handlers to fire

--------


Las excepciones que sean gordas las podemos redirigir desde la misma excepción:

@Redirect(viewId="/failure.xhtml", end=true)
@ApplicationException
public class UnrecoverableApplicationException extends RuntimeException { ... }


Esta excepción hace que se redirija siempre que se propague fuera de la capa de componentes Seam. Asímismo finaliza la conversación.

-----

hay que declarar en el components.xml:

<core:resource-loader>
<core:bundle-names>
<value>messages</value>
</core:bundle-names>
</core:resource-loader>

---------

cualquiera de estas dos formas de coger los mensajes en la excepción funciona:

String msg1 = SeamResourceBundle.getBundle().getString("exception.myexception");


String msg2 = ResourceBundle.getBundle("messages", FacesContext.getCurrentInstance().getViewRoot().getLocale()).getString("exception.myexception");


-------------

En el messages.properties:

exception.message1=Eureka, dijo {0}

Esta excepción funciona:

import org.jboss.seam.core.Interpolator;
import org.jboss.seam.core.SeamResourceBundle;

public class MyException extends Exception {

@Override
public String getMessage() {

String msg1 = SeamResourceBundle.getBundle().getString(
"exception.message1");
String msg2 = Interpolator.instance().interpolate(msg1, "Arquímedes");

return msg2;
}
}

21 septiembre 2009

exception management in pages.xml

14.4., “Use pages.xml for System
Exceptions”



from booking example:



pages.xml


You must be logged in to use this feature





Session expired, please log in again