【学习】SpringBoot之全局异常处理器

/**
 * 全局异常处理器
 **/
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Map<String,Object> handlerException(Exception exception){
        Map<String,Object> map = new HashMap<String ,Object>();
        map.put("errorCode","500");
        map.put("errorMsg",exception.toString());
        return map;
    }

}

  

posted @ 2019-05-14 15:23  快速奔跑的大米粒  阅读(337)  评论(0编辑  收藏  举报