package com.skr.mdm.handle;

import com.skr.mdm.result.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @author nfq
 * @date 2020/8/14 17:03
 * 统一异常处理
 */
@ControllerAdvice
@ResponseBody
@Slf4j
public class ExceptionControllerHandler {

    @ExceptionHandler(Exception.class)
    public ResponseResult exceptionHandle(HttpServletRequest request, Exception e) {
        log.error("全局异常处理 URI：" + request.getRequestURI(), e);
        return ResponseResult.failure();
    }

}
