【问题标题】:How to use exception mapper for exceptions thrown from interceptors in MSF4J如何对 MSF4J 中的拦截器抛出的异常使用异常映射器
【发布时间】:2017-01-17 10:29:25
【问题描述】:

我在拦截器中添加了一个授权模块,并尝试使用异常映射器抛出401状态码,但是即使它正在扫描我的异常映射器,它也没有在运行时使用它。

@Component
public class ExceptionMapper implements javax.ws.rs.ext.ExceptionMapper<Exception> {
    public ExceptionMapper() {
        System.out.println("true Manish= " + true);
    }
@Override
public Response toResponse(Exception exception) {
    System.out.println("product Manish Exception comning here");
    return Response.status(Response.Status.EXPECTATION_FAILED).
            entity(exception.getMessage()).
            type("text/plain").
            build();
}
}

所以,它打印的是 true Manish=true,但是当我的拦截器抛出异常时,它不会命中 toResponse() 方法

【问题讨论】:

    标签: msf4j wso2msf4j


    【解决方案1】:

    目前 MSF4J 无法映射从拦截器级别抛出的异常。它只能映射实际服务中抛出的异常。我们希望将其增强为拥有全局异常映射器。 https://github.com/wso2/msf4j/issues/327 就是为此创建的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-25
      • 2012-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-15
      • 2022-08-04
      • 1970-01-01
      相关资源
      最近更新 更多