GlobalExceptionHandler.java
760 Bytes
package com.glsx.smart.exception;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
@RestControllerAdvice
public class GlobalExceptionHandler {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@ExceptionHandler(BusinessException.class)
public void handleBusinessException(BusinessException e) {
logger.error("!!!! 业务异常", e);
}
@ExceptionHandler(Exception.class)
public void handleException(Exception e) {
logger.error("!!!! 未知异常", e);
}
}