📜  JAXRS 异常映射器 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:33.391000             🧑  作者: Mango

代码示例1
@Provider 
public class PersistenceMapper implements ExceptionMapper { 

    @Override 
    public Response toResponse(PersistenceException arg0) { 
        if(arg0.getCause() instanceof InvalidDataException) {
           return Response.status(Response.Status.BAD_REQUEST).build(); 
        } else {
           ...
        }
    } 

}