Hello,
see chapter 3.3.4 in the JAX-RS spec:
...
  Unchecked exceptions and errors MUST be re-thrown and allowed to 
propagate to the underlying
container
...
You can create your custom exception or throw WebApplicationException 
directly (see 
http://jsr311.java.net/nonav/javadoc/javax/ws/rs/WebApplicationException.html) 
- you can set the response there.
Regards,
Pavel
On 1/28/12 12:31 AM, sstaley wrote:
> Hello,
> I'm having a problem with mapping an exception using jersey 1.3 and embedded
> jetty 6.1.  Jersey is working great in all other respects in my application.
> I have a resource class which contains the following:
>
> @Path("/pinvalidation/{transactionId}/{pin}")
> @Provider
> public class PinValidationResource extends MHCResource implements
>          ExceptionMapper<java.lang.IllegalArgumentException>
> {
>
> ....
>
>      @Override
>      public Response toResponse(IllegalArgumentException arg0) {
>          Log.info("*********************");
>          return Response.ok().entity(
>                  new
> MHCResponse.Builder(MHCResponseResultCode.RESULT_CLOSE_SESSION).build()
>                  ).build();
>
>      }
>
> And from a method which handles POST requests, I do some validation and
> throw a new IllegalArgumentException.  But, code in toResponse isn't being
> invoked and the exception makes it's way to the container instead.  I have
> found a Jersey exception:
>
> <record>
>    <date>2012-01-27T15:12:45</date>
>    <millis>1327705965987</millis>
>    <sequence>11</sequence>
>    <logger>com.sun.jersey.spi.container.ContainerResponse</logger>
>    <level>SEVERE</level>
>    <class>com.sun.jersey.spi.container.ContainerResponse</class>
>    <method>mapMappableContainerException</method>
>    <thread>11</thread>
>    <message>The RuntimeException could not be mapped to a response,
> re-throwing to the HTTP container</message>
>    <exception>
>      <message>java.lang.IllegalArgumentException: No enum const class
> com.boku.mhc.services.PinType.uth</message>
>
> Any ideas?
>
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/exception-mapping-not-working-tp7231462p7231462.html
> Sent from the Jersey mailing list archive at Nabble.com.
>