//package com.zhgd.exception;
//
//import com.zhgd.jeecg.common.api.vo.Result;
//import com.zhgd.jeecg.common.execption.OpenAlertException;
//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;
//import javax.servlet.http.HttpServletResponse;
//
///**
// * @program: itbgpproject
// * @description: 统一异常处理
// * @author: Mr.Peng
// * @create: 2020-08-05 14:53
// **/
//@ResponseBody
//@Slf4j
//@ControllerAdvice
//public class ExceptionHandlerAdvice {
//
//    @ExceptionHandler(Exception.class)
//    @ResponseBody
//    public Result<Object> restError(HttpServletRequest request, HttpServletResponse response, Exception ex) {
//        Result<Object> result = new Result<>();
//        if (ex instanceof OpenAlertException) {
//            OpenAlertException e = (OpenAlertException) ex;
//            result.setCode(e.getCode());
//            result.setMessage(e.getMessage());
//            result.setSuccess(false);
//        } else if (ex instanceof CustomException) {
//            CustomException appException = (CustomException) ex;
//            result.setCode(403);
//            result.setMessage(appException.getMessage());
//            result.setSuccess(false);
//        } else {
//            result.error500(ex.getMessage() == null ? "操作中出现空指针！" : ex.getMessage());
//            ex.printStackTrace();
//        }
//        log.error("请求路径：" + request.getRequestURI() + "--" + result.getMessage());
//        return result;
//    }
//}
