CXF/ JAX-RS : Return Custom response from interceptor

前端 未结 2 429
忘了有多久
忘了有多久 2021-01-02 07:21

We need to return custom error code and error message when exception occurs during REST invocation. We have created a exception mapper provider, it works well for the except

2条回答
  •  甜味超标
    2021-01-02 07:55

    I raised a similar question on the cxf user group, see:

    http://cxf.547215.n5.nabble.com/Handling-exceptions-in-a-JAX-RS-fault-interceptor-when-using-Local-Transport-td5733958.html

    I ended up replacing my interceptors with ContainerRequestFilter and ContainerResponseFilter and then the Exception Mapper happily handled both application exceptions and exceptions thrown from the Filter.

    Hope this helps.

提交回复
热议问题