开发者

Call ExceptionMapper from another ExceptionMapper in JAX-RS

开发者 https://www.devze.com 2023-01-06 23:46 出处:网络
In my RESTEasy application I\'m getting a java.lang.reflect.UndeclaredThrowableException, because a checked exception is being thrown from a method that doesn\'t declare the exception in the throws 开

In my RESTEasy application I'm getting a java.lang.reflect.UndeclaredThrowableException, because a checked exception is being thrown from a method that doesn't declare the exception in the throws 开发者_JAVA百科clause.

So I'm writing an UndeclaredThrowableExceptionMapper. The UndeclaredThrowableException wraps the real exception; I call e.getCause() to retrieve it.

Can I then throw it or somehow look up the proper ExceptionMapper to handle it?


You can try adding a @Context javax.ws.rs.ext.Providers field/property to your UndeclaredThrowableExceptionMapper class.
Then use Providers.getExceptionMapper(Class) to look up the real exception mapper you want to use.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号