admin管理员组文章数量:1289565
In my QuarkusApplication I need a dedicated errorhandling for all servererros. Meaning every Exception occuring inside my Controller-Logic needs to be handled by my ExceptionMapper
, Quarkus' error handling of client-failures should not be affected.
First idea:
class MyDefautlExceptionMapper implements ExceptionMapper<Exception> {
// ...
}
This does as expected for my servererrors, but gets also triggered i.e. when the user calls a wrong url and should get a 404, or if a wrong method is used and should be answered by 405.
One solution would be to add a try catch to every controller-method and map everything to some dedicated Exception and handle that one
@GET
@Path("/foo")
public Baa handleRequest() {
try {
// do what to do
} catch (Exception e) {
throw MySpecialException();
}
and
class MySpecialExceptionMapper implements ExceptionMapper<MySpecialException> {
// ...
}
But that's ugly and error-prone when being added to dozens of methods. What's the right approach to my problem?
本文标签: restDefault ExceptionMapper for QuarkusStack Overflow
版权声明:本文标题:rest - Default ExceptionMapper for Quarkus - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741436195a2378652.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论