异常映射器的执行顺序
我有一个异常映射器,如下所示
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
@Provider
public class NotFoundMapper implements ExceptionMapper<NotFoundException> {
private final Logger log = LoggerFactory.getLogger(getClass());
private final MapperResponseBuilder responseBuilder = new MapperResponseBuilder();
@Override
public Response toResponse(NotFoundException ex) {
log.warn("NotFoundException : " + ex.getMessage(), ex);
return responseBuilder.buildErrorResponse(ex.getMessage(), Status.BAD_REQUEST);
}
}
因此,NotFoundException是一个RuntimeException。我希望有3个异常映射器,这些映射器映射
- NotFound具有更高优先级的异常
- 运行时具有下一个优先级的异常
- 最后例外
有没有办法优先考虑这些?