额外异常
This commit is contained in:
@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
import org.springframework.web.servlet.resource.NoResourceFoundException;
|
||||
|
||||
import java.util.List;
|
||||
@@ -78,6 +79,14 @@ public class CzgControllerAdvice {
|
||||
return CzgResult.failure(CzgRespCode.PARAM_ERROR.getCode(), message);
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = MethodArgumentTypeMismatchException.class)
|
||||
public CzgResult<Object> methodArgumentTypeMismatchException(MethodArgumentTypeMismatchException ex) {
|
||||
log.error("参数类型转换异常:{}", ex.getMessage());
|
||||
return CzgResult.failure(CzgRespCode.PARAM_ERROR.getCode(), ex.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 处理自定义异常
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user