Repository: huaweicloud/sermant
Issue: 【bug】fix the registry plugin bugs

### What happened?

can not work

### How can we reproduce it (as minimally and precisely as possible)?

no

### Anything else we need to know?

_No response_

### Sermant version

<details>
0.6.0
</details>


### OS version

<details>

```console
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
```
</details>


Changed files:
sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/entity/ExecuteContext.java
sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/AdviceConstTemplate.java
sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/AdviceMemberTemplate.java
sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/interceptors/FeignInvokeInterceptor.java
sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/interceptors/RestTemplateInterceptor.java
sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/CommonMethodAdviser.java
sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/CommonBaseAdviser.java
sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/CommonConstAdviser.java
sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/AdviceStaticTemplate.java

diff --git a/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/entity/ExecuteContext.java b/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/entity/ExecuteContext.java
index 983044d0..900dae41 100644
--- a/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/entity/ExecuteContext.java
+++ b/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/entity/ExecuteContext.java
@@ -72,6 +72,11 @@ public class ExecuteContext {
      */
     private Throwable throwable;
 
+    /**
+     * 抛出给宿主的异常
+     */
+    private Throwable throwableOut;
+
     /**
      * 额外的静态属性
      */
@@ -208,6 +213,10 @@ public class ExecuteContext {
         return throwable;
     }
 
+    public Throwable getThrowableOut() {
+        return throwableOut;
+    }
+
     public Map<String, Object> getExtStaticFields() {
         return extStaticFields;
     }
@@ -528,6 +537,17 @@ public class ExecuteContext {
         return this;
     }
 
+    /**
+     * 给宿主抛出异常
+     *
+     * @param throwableOut 抛出给宿主的异常
+     * @return 执行上下文
+     */
+    public ExecuteContext setThrowableOut(Throwable throwableOut) {
+        this.throwableOut = throwableOut;
+        return this;
+    }
+
     @Override
     public String toString() {
         return "ExecuteContext{"
diff --git a/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/AdviceConstTemplate.java b/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/AdviceConstTemplate.java
index 1e797cb2..f5e8453c 100644
--- a/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/AdviceConstTemplate.java
+++ b/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/AdviceConstTemplate.java
@@ -49,6 +49,7 @@ public class AdviceConstTemplate {
      * @param extStaticFields 额外静态属性集
      * @param interceptorItr  拦截器迭代器
      * @param context         执行上下文
+     * @throws Throwable      抛给宿主的异常
      */
     @Advice.OnMethodEnter(suppress = Throwable.class)
     public static void onMethodEnter(
@@ -60,7 +61,7 @@ public class AdviceConstTemplate {
             @Advice.FieldValue(value = "_EXT_STATIC_FIELDS_$SERMANT",
                     readOnly = false, typing = Assigner.Typing.DYNAMIC) Map<String, Object> extStaticFields,
             @Advice.Local(value = "_INTERCEPTOR_ITR_$SERMANT_LOCAL") ListIterator<Interceptor> interceptorItr,
-            @Advice.Local(value = "_EXECUTE_CONTEXT_$SERMANT_LOCAL") ExecuteContext context) {
+            @Advice.Local(value = "_EXECUTE_CONTEXT_$SERMANT_LOCAL") ExecuteContext context) throws Throwable {
         interceptorItr = interceptorMap.get(methodKey).listIterator();
         context = ExecuteContext.forConstructor(cls, constructor, arguments, extStaticFields);
         context = CommonConstAdviser.onMethodEnter(context, interceptorItr);
@@ -76,6 +77,7 @@ public class AdviceConstTemplate {
      * @param extMemberFields 额外成员属性集
      * @param interceptorItr  拦截器迭代器
      * @param context         执行上下文
+     * @throws Throwable      抛给宿主的异常
      */
     @Advice.OnMethodExit(suppress = Throwable.class)
     public static void onMethodExit(
@@ -85,7 +87,7 @@ public class AdviceConstTemplate {
             @Advice.FieldValue(value = "_EXT_MEMBER_FIELDS_$SERMANT",
                     readOnly = false, typing = Assigner.Typing.DYNAMIC) Map<String, Object> extMemberFields,
             @Advice.Local(value = "_INTERCEPTOR_ITR_$SERMANT_LOCAL") ListIterator<Interceptor> interceptorItr,
-            @Advice.Local(value = "_EXECUTE_CONTEXT_$SERMANT_LOCAL") ExecuteContext context) {
+            @Advice.Local(value = "_EXECUTE_CONTEXT_$SERMANT_LOCAL") ExecuteContext context) throws Throwable {
         context = CommonConstAdviser.onMethodExit(context.afterConstructor(obj, extMemberFields), interceptorItr);
         extStaticFields = context.getExtStaticFields();
         extMemberFields = context.getExtMemberFields();
diff --git a/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/AdviceMemberTemplate.java b/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/AdviceMemberTemplate.java
index c113def5..47c41d8b 100644
--- a/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/AdviceMemberTemplate.java
+++ b/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/AdviceMemberTemplate.java
@@ -51,6 +51,7 @@ public class AdviceMemberTemplate {
      * @param interceptorItr  拦截器迭代器
      * @param context         执行上下文
      * @return 是否跳过主要方法
+     * @throws Throwable      抛给宿主的异常
      */
     @Advice.OnMethodEnter(suppress = Throwable.class, skipOn = Advice.OnNonDefaultValue.class)
     public static boolean onMethodEnter(
@@ -64,7 +65,7 @@ public class AdviceMemberTemplate {
             @Advice.FieldValue(value = "_EXT_MEMBER_FIELDS_$SERMANT",
                     readOnly = false, typing = Assigner.Typing.DYNAMIC) Map<String, Object> extMemberFields,
             @Advice.Local(value = "_INTERCEPTOR_ITR_$SERMANT_LOCAL") ListIterator<Interceptor> interceptorItr,
-            @Advice.Local(value = "_EXECUTE_CONTEXT_$SERMANT_LOCAL") ExecuteContext context) {
+            @Advice.Local(value = "_EXECUTE_CONTEXT_$SERMANT_LOCAL") ExecuteContext context) throws Throwable {
         interceptorItr = interceptorMap.get(methodKey).listIterator();
         context = ExecuteContext.forMemberMethod(obj, method, arguments, extStaticFields, extMemberFields);
         context = CommonMethodAdviser.onMethodEnter(context, interceptorItr);
@@ -83,6 +84,7 @@ public class AdviceMemberTemplate {
      * @param extMemberFields 额外成员属性集
      * @param interceptorItr  拦截器迭代器
      * @param context         执行上下文
+     * @throws Throwable      抛给宿主的异常
      */
     @Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class)
     public static void onMethodExit(
@@ -93,7 +95,7 @@ public class AdviceMemberTemplate {
             @Advice.FieldValue(value = "_EXT_MEMBER_FIELDS_$SERMANT",
                     readOnly = false, typing = Assigner.Typing.DYNAMIC) Map<String, Object> extMemberFields,
             @Advice.Local(value = "_INTERCEPTOR_ITR_$SERMANT_LOCAL") ListIterator<Interceptor> interceptorItr,
-            @Advice.Local(value = "_EXECUTE_CONTEXT_$SERMANT_LOCAL") ExecuteContext context) {
+            @Advice.Local(value = "_EXECUTE_CONTEXT_$SERMANT_LOCAL") ExecuteContext context) throws Throwable {
         context = context.isSkip() ? context : context.afterMethod(result, throwable);
         context = CommonMethodAdviser.onMethodExit(context, interceptorItr);
         result = context.getResult();
diff --git a/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/AdviceStaticTemplate.java b/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/AdviceStaticTemplate.java
index 840462fb..a9b630c6 100644
--- a/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/AdviceStaticTemplate.java
+++ b/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/AdviceStaticTemplate.java
@@ -50,6 +50,7 @@ public class AdviceStaticTemplate {
      * @param interceptorItr  拦截器迭代器
      * @param context         执行上下文
      * @return 是否跳过主要方法
+     * @throws Throwable      抛给宿主的异常
      */
     @Advice.OnMethodEnter(suppress = Throwable.class, skipOn = Advice.OnNonDefaultValue.class)
     public static boolean onMethodEnter(
@@ -61,7 +62,7 @@ public class AdviceStaticTemplate {
             @Advice.FieldValue(value = "_EXT_STATIC_FIELDS_$SERMANT",
                     readOnly = false, typing = Assigner.Typing.DYNAMIC) Map<String, Object> extStaticFields,
             @Advice.Local(value = "_INTERCEPTOR_ITR_$SERMANT_LOCAL") ListIterator<Interceptor> interceptorItr,
-            @Advice.Local(value = "_EXECUTE_CONTEXT_$SERMANT_LOCAL") ExecuteContext context) {
+            @Advice.Local(value = "_EXECUTE_CONTEXT_$SERMANT_LOCAL") ExecuteContext context) throws Throwable {
         interceptorItr = interceptorMap.get(methodKey).listIterator();
         context = ExecuteContext.forStaticMethod(cls, method, arguments, extStaticFields);
         context = CommonMethodAdviser.onMethodEnter(context, interceptorItr);
@@ -78,6 +79,7 @@ public class AdviceStaticTemplate {
      * @param extStaticFields 额外静态属性集
      * @param interceptorItr  拦截器迭代器
      * @param context         执行上下文
+     * @throws Throwable      抛给宿主的异常
      */
     @Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class)
     public static void onMethodExit(
@@ -86,7 +88,7 @@ public class AdviceStaticTemplate {
             @Advice.FieldValue(value = "_EXT_STATIC_FIELDS_$SERMANT",
                     readOnly = false, typing = Assigner.Typing.DYNAMIC) Map<String, Object> extStaticFields,
             @Advice.Local(value = "_INTERCEPTOR_ITR_$SERMANT_LOCAL") ListIterator<Interceptor> interceptorItr,
-            @Advice.Local(value = "_EXECUTE_CONTEXT_$SERMANT_LOCAL") ExecuteContext context) {
+            @Advice.Local(value = "_EXECUTE_CONTEXT_$SERMANT_LOCAL") ExecuteContext context) throws Throwable {
         context = context.isSkip() ? context : context.afterMethod(result, throwable);
         context = CommonMethodAdviser.onMethodExit(context, interceptorItr);
         result = context.getResult();
diff --git a/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/CommonBaseAdviser.java b/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/CommonBaseAdviser.java
index a2ca77db..06efe3ea 100644
--- a/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/CommonBaseAdviser.java
+++ b/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/CommonBaseAdviser.java
@@ -39,9 +39,10 @@ public class CommonBaseAdviser {
      * @param interceptorItr 拦截器双向迭代器
      * @param beforeHandler  before的异常处理器
      * @return 执行上下文
+     * @throws Throwable     抛给宿主的异常
      */
     public static ExecuteContext onMethodEnter(ExecuteContext context, ListIterator<Interceptor> interceptorItr,
-            ExceptionHandler beforeHandler) {
+            ExceptionHandler beforeHandler) throws Throwable {
         ExecuteContext newContext = context;
         while (interceptorItr.hasNext()) {
             final Interceptor interceptor = interceptorItr.next();
@@ -56,6 +57,9 @@ public class CommonBaseAdviser {
             } catch (Throwable t) {
                 beforeHandler.handle(context, interceptor, t);
             }
+            if (newContext.getThrowableOut() != null) {
+                throw newContext.getThrowableOut();
+            }
         }
         return newContext;
     }
@@ -68,9 +72,10 @@ public class CommonBaseAdviser {
      * @param onThrowHandler onThrow的异常处理器
      * @param afterHandler   after的的异常处理器
      * @return 执行上下文
+     * @throws Throwable     抛给宿主的异常
      */
     public static ExecuteContext onMethodExit(ExecuteContext context, ListIterator<Interceptor> interceptorItr,
-            ExceptionHandler onThrowHandler, ExceptionHandler afterHandler) {
+            ExceptionHandler onThrowHandler, ExceptionHandler afterHandler) throws Throwable {
         ExecuteContext newContext = context;
         while (interceptorItr.hasPrevious()) {
             final Interceptor interceptor = interceptorItr.previous();
@@ -83,6 +88,9 @@ public class CommonBaseAdviser {
                 } catch (Throwable t) {
                     onThrowHandler.handle(newContext, interceptor, t);
                 }
+                if (newContext.getThrowableOut() != null) {
+                    throw newContext.getThrowableOut();
+                }
             }
             try {
                 final ExecuteContext tempContext = interceptor.after(newContext);
@@ -92,6 +100,9 @@ public class CommonBaseAdviser {
             } catch (Throwable t) {
                 afterHandler.handle(newContext, interceptor, t);
             }
+            if (newContext.getThrowableOut() != null) {
+                throw newContext.getThrowableOut();
+            }
         }
         return newContext;
     }
diff --git a/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/CommonConstAdviser.java b/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/CommonConstAdviser.java
index fe80c975..2a8b7161 100644
--- a/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/CommonConstAdviser.java
+++ b/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/CommonConstAdviser.java
@@ -61,8 +61,10 @@ public class CommonConstAdviser {
      * @param context        执行上下文
      * @param interceptorItr 拦截器双向迭代器
      * @return 执行上下文
+     * @throws Throwable     抛给宿主的异常
      */
-    public static ExecuteContext onMethodEnter(ExecuteContext context, ListIterator<Interceptor> interceptorItr) {
+    public static ExecuteContext onMethodEnter(ExecuteContext context, ListIterator<Interceptor> interceptorItr)
+        throws Throwable {
         return CommonBaseAdviser.onMethodEnter(context, interceptorItr,
                 new CommonBaseAdviser.ExceptionHandler() {
                     @Override
@@ -78,8 +80,10 @@ public class CommonConstAdviser {
      * @param context        执行上下文
      * @param interceptorItr 拦截器双向迭代器
      * @return 执行上下文
+     * @throws Throwable     抛给宿主的异常
      */
-    public static ExecuteContext onMethodExit(ExecuteContext context, ListIterator<Interceptor> interceptorItr) {
+    public static ExecuteContext onMethodExit(ExecuteContext context, ListIterator<Interceptor> interceptorItr)
+        throws Throwable {
         return CommonBaseAdviser.onMethodExit(context, interceptorItr, null,
                 new CommonBaseAdviser.ExceptionHandler() {
                     @Override
diff --git a/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/CommonMethodAdviser.java b/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/CommonMethodAdviser.java
index d7909964..3724811d 100644
--- a/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/CommonMethodAdviser.java
+++ b/sermant-agentcore/sermant-agentcore-core/src/main/java/com/huaweicloud/sermant/core/plugin/agent/template/CommonMethodAdviser.java
@@ -61,8 +61,10 @@ public class CommonMethodAdviser {
      * @param context        执行上下文
      * @param interceptorItr 拦截器双向迭代器
      * @return 执行上下文
+     * @throws Throwable     抛给宿主的异常
      */
-    public static ExecuteContext onMethodEnter(ExecuteContext context, ListIterator<Interceptor> interceptorItr) {
+    public static ExecuteContext onMethodEnter(ExecuteContext context, ListIterator<Interceptor> interceptorItr)
+        throws Throwable {
         return CommonBaseAdviser.onMethodEnter(context, interceptorItr,
                 new CommonBaseAdviser.ExceptionHandler() {
                     @Override
@@ -78,8 +80,10 @@ public class CommonMethodAdviser {
      * @param context        执行上下文
      * @param interceptorItr 拦截器双向迭代器
      * @return 执行上下文
+     * @throws Throwable     抛给宿主的异常
      */
-    public static ExecuteContext onMethodExit(ExecuteContext context, ListIterator<Interceptor> interceptorItr) {
+    public static ExecuteContext onMethodExit(ExecuteContext context, ListIterator<Interceptor> interceptorItr)
+        throws Throwable {
         return CommonBaseAdviser.onMethodExit(context, interceptorItr,
                 new CommonBaseAdviser.ExceptionHandler() {
                     @Override
diff --git a/sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/interceptors/FeignInvokeInterceptor.java b/sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/interceptors/FeignInvokeInterceptor.java
index 498ff966..e905e354 100644
--- a/sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/interceptors/FeignInvokeInterceptor.java
+++ b/sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/interceptors/FeignInvokeInterceptor.java
@@ -22,16 +22,17 @@ import com.huawei.discovery.utils.HttpConstants;
 import com.huawei.discovery.utils.PlugEffectWhiteBlackUtils;
 import com.huawei.discovery.utils.RequestInterceptorUtils;
 
+import com.huaweicloud.sermant.core.common.LoggerFactory;
 import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext;
 import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager;
 
 import feign.Request;
-import feign.Response;
-
-import org.apache.http.HttpStatus;
 
 import java.util.Map;
+import java.util.Optional;
 import java.util.function.Function;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
  * 拦截获取服务列表
@@ -40,22 +41,31 @@ import java.util.function.Function;
  * @since 2022-09-27
  */
 public class FeignInvokeInterceptor extends MarkInterceptor {
+    private static final Logger LOGGER = LoggerFactory.getLogger();
 
     @Override
     protected ExecuteContext doBefore(ExecuteContext context) throws Exception {
         final InvokerService invokerService = PluginServiceManager.getPluginService(InvokerService.class);
-        Request request = (Request)context.getArguments()[0];
+        Request request = (Request) context.getArguments()[0];
         Map<String, String> urlInfo = RequestInterceptorUtils.recovertUrl(request.url());
         if (!PlugEffectWhiteBlackUtils.isAllowRun(request.url(), urlInfo.get(HttpConstants.HTTP_URI_HOST),
             false)) {
             return context;
         }
         RequestInterceptorUtils.printRequestLog("feign", urlInfo);
-        invokerService.invoke(
-                buildInvokerFunc(context, request, urlInfo),
-                buildExFunc(request),
-                urlInfo.get(HttpConstants.HTTP_URI_HOST))
-                .ifPresent(context::skip);
+        Optional<Object> result = invokerService.invoke(
+            buildInvokerFunc(context, request, urlInfo),
+            ex -> ex,
+            urlInfo.get(HttpConstants.HTTP_URI_HOST));
+        if (result.isPresent()) {
+            Object obj = result.get();
+            if (obj instanceof Exception) {
+                LOGGER.log(Level.SEVERE, "request is error, uri is " + request.url(), (Exception) obj);
+                context.setThrowableOut((Exception) obj);
+                return context;
+            }
+            context.skip(obj);
+        }
         return context;
     }
 
@@ -69,24 +79,6 @@ public class FeignInvokeInterceptor extends MarkInterceptor {
         };
     }
 
-    private Function<Exception, Object> buildExFunc(Request request) {
-        return ex -> buildErrorResponse(ex, request);
-    }
-
-    /**
-     * 构建feign响应
-     *
-     * @param ex
-     * @return 响应
-     */
-    private Response buildErrorResponse(Exception ex, Request request) {
-        Response.Builder builder = Response.builder();
-        builder.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-        builder.reason(ex.getMessage());
-        builder.request(request);
-        return builder.build();
-    }
-
     @Override
     public ExecuteContext after(ExecuteContext context) throws Exception {
         return context;
diff --git a/sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/interceptors/RestTemplateInterceptor.java b/sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/interceptors/RestTemplateInterceptor.java
index 080eeaca..62181676 100644
--- a/sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/interceptors/RestTemplateInterceptor.java
+++ b/sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/interceptors/RestTemplateInterceptor.java
@@ -58,12 +58,13 @@ public class RestTemplateInterceptor extends MarkInterceptor {
         RequestInterceptorUtils.printRequestLog("restTemplate", hostAndPath);
         Optional<Object> result = invokerService.invoke(
             buildInvokerFunc(uri, hostAndPath, context, httpMethod),
-            this::buildErrorResponse,
+            ex -> ex,
             hostAndPath.get(HttpConstants.HTTP_URI_HOST));
         if (result.isPresent()) {
             Object obj = result.get();
             if (obj instanceof Exception) {
                 LOGGER.log(Level.SEVERE, "request is error, uri is " + uri, (Exception) obj);
+                context.setThrowableOut((Exception) obj);
                 return context;
             }
             context.skip(obj);
@@ -101,16 +102,6 @@ public class RestTemplateInterceptor extends MarkInterceptor {
         };
     }
 
-    /**
-     * 构建restTemplete响应
-     *
-     * @param ex
-     * @return 响应
-     */
-    private Exception buildErrorResponse(Exception ex) {
-        return ex;
-    }
-
     @Override
     public ExecuteContext after(ExecuteContext context) throws Exception {
         return context;