Hi Bill,
sounds very good. But only for environments supporting EJBs.
best regards
Stephan
> I'm doing an EJB example in my book and came across the scenario of
> EJBException. Maybe the spec should define a default ExceptionMapper
> for it? Here's a simple one I did:
>
> @Provider
> public class EJBExceptionMapper implements ExceptionMapper<EJBException>
> {
> @Context
> private Providers providers;
>
> public Response toResponse(EJBException exception)
> {
> if (exception.getCausedByException() == null)
> {
> return Response.serverError().build();
> }
> Class cause = exception.getCausedByException().getClass();
> ExceptionMapper mapper = providers.getExceptionMapper(cause);
> if (mapper == null)
> {
> return Response.serverError().build();
> }
> else
> {
> return mapper.toResponse(exception.getCausedByException());
> }
> }
> }
>