Global Exception Handling in Jersey

前端 未结 3 1125
耶瑟儿~
耶瑟儿~ 2021-02-01 14:01

Is there a way to have global exception handling in Jersey? Instead of individual resources having try/catch blocks and then calling some method that then sanitizes all of the

3条回答
  •  轮回少年
    2021-02-01 14:09

    Yes. JAX-RS has a concept of ExceptionMappers. You can create your own ExceptionMapper interface to map any exception to a response. For more info see: https://jersey.github.io/documentation/latest/representations.html#d0e6352

提交回复
热议问题