Commit 0001cfe8 by 丁伟峰

增加了全局的错误处理返回

1 parent 4f0aff28
package com.alibaba.cloud.integration.order.controller;
import com.alibaba.cloud.integration.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindException;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.MethodArgumentNotValidException;
......@@ -12,6 +13,7 @@ import javax.validation.ConstraintViolationException;
import javax.validation.ValidationException;
import java.util.stream.Collectors;
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
......@@ -19,6 +21,8 @@ public class GlobalExceptionHandler {
public Result<?> handleValidatedException(Exception e) {
Result<?> resp = null;
log.error(e.toString());
if (e instanceof MethodArgumentNotValidException) {
// BeanValidation exception
MethodArgumentNotValidException ex = (MethodArgumentNotValidException) e;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!