users@jersey.java.net

[Jersey] Re: ExceptionMapper does not catch java.lang.Error

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Tue, 25 Oct 2011 11:49:39 +0200

Hi,
From the JAX-RS 1.1 spec, chapter 4.4:

"Exception mapping providers map a checked or runtime exception to an instance of Response."

java.lang.Error is not an exception. The observed behavior is correct.

HTH,
Marek


On 10/25/2011 10:40 AM, Jordan Blay wrote:
> Hi!
>
> I defined 2 classes that implement exceptionmapper.
>
> The first one:
>
> public class JsonExceptionMapper implements
> ExceptionMapper<IndexOutOfBoundsException>
>
> The second one:
>
> public class ErrorExceptionMapper implements ExceptionMapper<Error>
>
> The second one is to catch the error from here:
>
> java.lang.Error: Error: could not match input
> at
> com.sun.jersey.json.impl.reader.JsonLexer.zzScanError(JsonLexer.java:491)
> at com.sun.jersey.json.impl.reader.JsonLexer.yylex(JsonLexer.java:736)
> at
> com.sun.jersey.json.impl.reader.JsonXmlStreamReader.nextToken(JsonXmlStreamReader.java:160)
>
> However it doesn't catch it! only the first one works if there is
> IndexOutOfBound exception!
>
> Is it a bug?
>
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/ExceptionMapper-does-not-catch-java-lang-Error-tp6928025p6928025.html
> Sent from the Jersey mailing list archive at Nabble.com.