/**
* <P><B>Description: </B>全局异常处理</P>
* Revision Trail: (Date/Author/Description)
* 2022/9/27 Ryan Huang CREATE
*
* @author Ryan Huang
* @version 1.0
*/
@ControllerAdvice
public class GlobalExceptionHandler {
@ResponseBody
@ExceptionHandler(value = Exception.class)
public Object customerExceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception e){
Object result;
if(e instanceof RuntimeException){
//异常处理
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
result = "异常操作1";
}else{
result = "异常操作2";
}
return result;
}
}