@@ -76,15 +76,13 @@ public abstract class AbstractContractCode implements ContractCode { | |||||
BytesValueList bytesValues = eventContext.getArgs(); | BytesValueList bytesValues = eventContext.getArgs(); | ||||
Object[] args = BytesValueEncoding.decode(bytesValues, handleMethod.getParameterTypes()); | Object[] args = BytesValueEncoding.decode(bytesValues, handleMethod.getParameterTypes()); | ||||
try { | |||||
retn = ReflectionUtils.invokeMethod(handleMethod, contractInstance, args); | |||||
} catch (Throwable e) { | |||||
throw new ContractExecuteException(String.format("Contract[%s:%s] has no handle method to handle event[%s]!", address.toString(), | |||||
contractDefinition.getType().getName(), eventContext.getEvent())); | |||||
} | |||||
retn = ReflectionUtils.invokeMethod(handleMethod, contractInstance, args); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
error = e; | error = e; | ||||
} catch (Error e) { | |||||
throw new ContractExecuteException(String.format("Contract[%s:%s] has no handle method to handle event[%s]!", address.toString(), | |||||
contractDefinition.getType().getName(), eventContext.getEvent())); | |||||
} | } | ||||
if (evtProcAwire != null) { | if (evtProcAwire != null) { | ||||
@@ -13,6 +13,7 @@ public class ContractExecuteException extends LedgerException { | |||||
public ContractExecuteException(String message, Throwable cause) { | public ContractExecuteException(String message, Throwable cause) { | ||||
super(message, cause); | super(message, cause); | ||||
setState(TransactionState.CONTRACT_EXECUTE_ERROR); | |||||
} | } | ||||
public ContractExecuteException() { | public ContractExecuteException() { | ||||
@@ -15,5 +15,11 @@ | |||||
<artifactId>utils-common</artifactId> | <artifactId>utils-common</artifactId> | ||||
<version>${project.version}</version> | <version>${project.version}</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | |||||
<groupId>com.jd.blockchain</groupId> | |||||
<artifactId>ledger-model</artifactId> | |||||
<version>${project.version}</version> | |||||
</dependency> | |||||
</dependencies> | </dependencies> | ||||
</project> | </project> |
@@ -3,6 +3,7 @@ package com.jd.blockchain.runtime; | |||||
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.util.concurrent.Callable; | import java.util.concurrent.Callable; | ||||
import com.jd.blockchain.ledger.ContractExecuteException; | |||||
import com.jd.blockchain.utils.concurrent.AsyncFuture; | import com.jd.blockchain.utils.concurrent.AsyncFuture; | ||||
import com.jd.blockchain.utils.concurrent.CompletableAsyncFuture; | import com.jd.blockchain.utils.concurrent.CompletableAsyncFuture; | ||||
@@ -93,7 +94,7 @@ public abstract class AbstractModule implements Module { | |||||
try { | try { | ||||
return callable.call(); | return callable.call(); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
throw new IllegalStateException(e.getMessage(), e); | |||||
throw new ContractExecuteException(e.getMessage(), e); | |||||
} finally { | } finally { | ||||
if (origClassLoader != Thread.currentThread().getContextClassLoader()) { | if (origClassLoader != Thread.currentThread().getContextClassLoader()) { | ||||
Thread.currentThread().setContextClassLoader(origClassLoader); | Thread.currentThread().setContextClassLoader(origClassLoader); | ||||