On Mar 27, 2009, at 5:18 PM, Andrew Ochsner wrote:
> Hi:
>
> I have a set of ExceptionMappers that look for particular runtime
> exceptions that i've created and maps them accordingly.
>
> I'd also like a generic one that looks for RuntimeExceptions and
> strips out the stack trace essentially.
>
> If I create an ExceptionMapper that converts RuntimException, what
> happens when I throw one of my specific ones for which there is a
> more specific mapper for?
>
> Sorry, hope that makes sense. Basically I want it to match as close
> as it can so that the specific mappers i've written get used before
> the generic RuntimeException mapper.
>
> Can this work?
Yes. See here:
https://jsr311.dev.java.net/nonav/releases/1.0/spec/
spec3.html#x3-510004.4
Specifically:
When choosing an exception mapping provider to map an exception, an
implementation MUST use the provider whose generic type is the nearest
superclass of the exception.
Paul.