Skip to content

Commit 02d59f6

Browse files
authored
fix(interactive): Add JNI Logging (#4610)
<!-- Thanks for your contribution! please review https://github.com/alibaba/GraphScope/blob/main/CONTRIBUTING.md before opening an issue. --> ## What do these changes do? as titled. <!-- Please give a short brief about these changes. --> ## Related issue number <!-- Are there any issues opened that will be resolved by merging this change? --> Fixes
1 parent 94c62dd commit 02d59f6

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/utils/ClassUtils.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import org.apache.commons.lang3.exception.ExceptionUtils;
3434
import org.checkerframework.checker.nullness.qual.Nullable;
3535

36+
import java.io.PrintWriter;
37+
import java.io.StringWriter;
3638
import java.math.BigInteger;
3739
import java.util.Map;
3840
import java.util.concurrent.Callable;
@@ -52,16 +54,25 @@ public static final <T> T callExceptionWithDetails(
5254
return callable.call();
5355
} catch (FrontendException e1) {
5456
e1.getDetails().putAll(details);
57+
e1.getDetails().put("stacktrace", getStackTrace(e1));
5558
throw e1;
5659
} catch (ExecutionException e2) {
5760
throw e2;
5861
} catch (Exception e3) {
5962
FrontendException e4 = new FrontendException(errorCode, e3.getMessage(), e3);
6063
e4.getDetails().putAll(details);
64+
e4.getDetails().put("stacktrace", getStackTrace(e3));
6165
throw e4;
6266
}
6367
}
6468

69+
public static String getStackTrace(Exception e) {
70+
StringWriter sw = new StringWriter();
71+
PrintWriter pw = new PrintWriter(sw);
72+
e.printStackTrace(pw);
73+
return sw.toString();
74+
}
75+
6576
/**
6677
*
6778
* @param query

interactive_engine/compiler/src/main/java/com/alibaba/graphscope/sdk/PlanUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ public static GraphPlan compilePlan(
8787
Code.OK, null, physicalPlan.getContent(), new String(metaStream.toByteArray()));
8888
} catch (Throwable t) {
8989
if (t instanceof FrontendException) {
90-
return new GraphPlan(
91-
((FrontendException) t).getErrorCode(), t.getMessage(), null, null);
90+
String errorMsg = t.getMessage().substring(0, 1024);
91+
return new GraphPlan(((FrontendException) t).getErrorCode(), errorMsg, null, null);
9292
}
9393
return new GraphPlan(Code.UNRECOGNIZED, t.getMessage(), null, null);
9494
}

0 commit comments

Comments
 (0)