From f329c6802a6f2c0f2ca77f432735f97b3c5d1a1a Mon Sep 17 00:00:00 2001 From: crusader Date: Mon, 14 Aug 2017 19:08:03 +0900 Subject: [PATCH] Error handling --- .../java/com/loafle/overflow/proxy/ServiceInvoker.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/loafle/overflow/proxy/ServiceInvoker.java b/src/main/java/com/loafle/overflow/proxy/ServiceInvoker.java index d9b3026..40012b5 100644 --- a/src/main/java/com/loafle/overflow/proxy/ServiceInvoker.java +++ b/src/main/java/com/loafle/overflow/proxy/ServiceInvoker.java @@ -2,6 +2,8 @@ package com.loafle.overflow.proxy; import com.google.gson.internal.Primitives; import com.google.protobuf.ByteString; +import com.loafle.overflow.commons.exception.OverflowException; +import com.loafle.overflow.commons.exception.OverflowRuntimeException; import com.loafle.overflow.proxy.exception.InvalidParameterException; import com.loafle.overflow.proxy.exception.InvalidRequestException; import com.loafle.overflow.proxy.exception.NoSuchMethodException; @@ -156,7 +158,7 @@ public class ServiceInvoker { } - public String invoke(String serviceName, String methodName, List params) throws Throwable { + public String invoke(String serviceName, String methodName, List params) throws OverflowException, OverflowRuntimeException { Cache serviceCache = getServiceCache(serviceName); Cache.MethodCache methodCache = serviceCache.getMethodCache(methodName); @@ -182,7 +184,11 @@ public class ServiceInvoker { } catch (IllegalAccessException e) { throw new InvalidRequestException(); } catch (InvocationTargetException e) { - throw e.getTargetException(); + Throwable t = e.getTargetException(); + if (t instanceof OverflowRuntimeException) { + throw (OverflowRuntimeException)t; + } + throw new InvalidRequestException(); } try {