From 487697aa8763cc5d8c36a609fcc530a524ad1219 Mon Sep 17 00:00:00 2001 From: CaiHQ Date: Wed, 15 Mar 2023 16:24:05 +0800 Subject: [PATCH] update for error log --- src/main/java/org/bdware/sc/ContractManager.java | 7 +++++-- src/test/java/org/bdware/sc/test/ContractManagerTest.java | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/bdware/sc/ContractManager.java b/src/main/java/org/bdware/sc/ContractManager.java index 206db32..90f5627 100644 --- a/src/main/java/org/bdware/sc/ContractManager.java +++ b/src/main/java/org/bdware/sc/ContractManager.java @@ -32,6 +32,8 @@ import org.zz.gmhelper.SM2KeyPair; import org.zz.gmhelper.SM2Util; import java.io.*; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.*; @@ -878,14 +880,15 @@ public class ContractManager { initLoadMemory(client); statusRecorder.createContract(client); loadProjectConfig(client); - return ret; default: return "contract manager can't support:" + c.getType(); } } catch (Exception e) { statusRecorder.killContract(c.getID()); - r = new ContractResult(Status.Error, new JsonPrimitive("exception occurs: " + e.getMessage())); + ByteArrayOutputStream bo = new ByteArrayOutputStream(); + e.printStackTrace(new PrintStream(bo)); + r = new ContractResult(Status.Error, new JsonPrimitive(bo.toString())); return JsonUtil.toJson(r); } } diff --git a/src/test/java/org/bdware/sc/test/ContractManagerTest.java b/src/test/java/org/bdware/sc/test/ContractManagerTest.java index d0dd955..0ec9ce6 100644 --- a/src/test/java/org/bdware/sc/test/ContractManagerTest.java +++ b/src/test/java/org/bdware/sc/test/ContractManagerTest.java @@ -1,10 +1,16 @@ package org.bdware.sc.test; import org.bdware.sc.ContractManager; +import org.bdware.sc.bean.Contract; +import org.junit.Test; + +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; public class ContractManagerTest { public static void main(String[] args) { ContractManager.yjsPath = "./generatedlib/yjs.jar"; ContractManager.instance = new ContractManager(); } + }