Error handling

This commit is contained in:
crusader 2017-08-14 19:08:03 +09:00
parent 8786d944cb
commit f329c6802a

View File

@ -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<ByteString> params) throws Throwable {
public String invoke(String serviceName, String methodName, List<ByteString> 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 {