package com.mx.cneeds.server.datashow.web.system;

import com.mx.cneeds.common.constant.ResultCode;
import com.mx.cneeds.common.result.R;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ClassName GlobalExceptionHandler
 * @Author zzrdark
 * @Date 2020-07-15 17:42
 * @Description 全局异常拦截
 **/
@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public R exceptionHandler(HttpServletRequest req, Exception e){
        log.error("Exception Message: "+ e.toString());
        e.printStackTrace();
        return R.error(ResultCode.NOTFOUND_EEROR,"系统未知异常");
    }

}
