Survey/src/main/java/com/example/survey/controller/advice/GlobalExceptionHandler.java
Pope dcf4b04e43 2021-3-19
修改了调查对象与流调记录部分接口
2021-03-19 20:49:22 +08:00

65 lines
1.9 KiB
Java

package com.example.survey.controller.advice;
import com.example.survey.exception.*;
import com.example.survey.vo.ResultVO;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* @author Pope
*/
@Log4j2
@RestControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(UserException.class)
public ResultVO handleUserException(UserException e) {
log.error(e.getMessage());
return new ResultVO(e.getResultEnum());
}
@ExceptionHandler(RecordException.class)
public ResultVO handleRecordException(RecordException e) {
log.error(e.getMessage());
return new ResultVO(e.getResultEnum());
}
@ExceptionHandler(RespondentException.class)
public ResultVO handleRespondentException(RespondentException e) {
log.error(e.getMessage());
return new ResultVO(e.getResultEnum());
}
@ExceptionHandler(RoleException.class)
public ResultVO handleRoleException(RoleException e) {
log.error(e.getMessage());
return new ResultVO(e.getResultEnum());
}
@ExceptionHandler(DepartmentException.class)
public ResultVO handleDepartmentException(DepartmentException e) {
log.error(e.getMessage());
return new ResultVO(e.getResultEnum());
}
@ExceptionHandler(AuthException.class)
public ResultVO handleAuthException(AuthException e) {
log.error(e.getMessage());
return new ResultVO(e.getResultEnum());
}
@ExceptionHandler(ProjectException.class)
public ResultVO handleProjectException(ProjectException e) {
log.error(e.getMessage());
return new ResultVO(e.getResultEnum());
}
@ExceptionHandler(MetaDataException.class)
public ResultVO handleMetaDataException(MetaDataException e) {
log.error(e.getMessage());
return new ResultVO(e.getResultEnum());
}
}