xujunwei 3 лет назад
Родитель
Сommit
6b2376dca9

+ 1 - 2
framework-boot/src/main/java/com/mrxu/framework/boot/handle/FeignErrorDecoder.java

@@ -30,7 +30,6 @@ public class FeignErrorDecoder implements ErrorDecoder {
     public @interface EnableFeignErrorDecoder {
     }
 
-    @SneakyThrows
     @Override
     public Exception decode(String methodKey, Response response) {
         try {
@@ -42,7 +41,7 @@ public class FeignErrorDecoder implements ErrorDecoder {
             }
             else {
                 String msg = feignError.getFromServiceName()+"->"+feignError.getServiceName()+"错误:"+feignError.getMsg();
-                throw new Exception(msg);
+                throw new RuntimeException(msg);
             }
         }
         catch (IOException ignored) {

+ 3 - 0
framework-boot/src/main/java/com/mrxu/framework/boot/handle/FeignProviderExceptionHandler.java

@@ -6,6 +6,8 @@ import com.mrxu.framework.common.util.BaseCode;
 import com.mrxu.framework.common.util.BusinessException;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
 import org.springframework.http.HttpStatus;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.MethodArgumentNotValidException;
@@ -22,6 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
 @ControllerAdvice
 @RestController
 @Slf4j
+@Order(Ordered.LOWEST_PRECEDENCE)
 public class FeignProviderExceptionHandler {
 
     // 当前服务名称

+ 3 - 0
framework-boot/src/main/java/com/mrxu/framework/boot/handle/WebExceptionHandler.java

@@ -8,6 +8,8 @@ import com.mrxu.framework.common.util.StrFunc;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Import;
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
 import org.springframework.validation.BindingResult;
 import org.springframework.validation.FieldError;
 import org.springframework.web.bind.MethodArgumentNotValidException;
@@ -27,6 +29,7 @@ import java.lang.annotation.*;
  */ 
 @ControllerAdvice
 @RestController
+@Order(Ordered.HIGHEST_PRECEDENCE)
 public class WebExceptionHandler {
 
     @Retention(RetentionPolicy.RUNTIME)