0

I added a authorisation module in interceptor, and tried to use exception mapper to throw 401 status code, but even if it is scanning my exception mapper, it is not using it in runtime.

@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();
}
}

So, it is printing true Manish=true, but when my interceptor throws an exception, it doesn't hit toResponse() method

krmanish007
  • 6,749
  • 16
  • 58
  • 100

1 Answers1

0

At the moment MSF4J can't map the exception which are get thrown from interceptor level. It only can map the exceptions which are thrown inside the actual service. We would like to enhance that to having global exception mappers. https://github.com/wso2/msf4j/issues/327 been created for that.