Skip to content

Commit d287785

Browse files
committed
#98: Do not include the j4rs parts of the stacktrace
1 parent c8427f5 commit d287785

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

java/src/main/java/org/astonbitecode/j4rs/utils/Utils.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616

1717
import java.io.PrintWriter;
1818
import java.io.StringWriter;
19+
import java.lang.reflect.InvocationTargetException;
1920
import java.util.Arrays;
2021

2122
import org.astonbitecode.j4rs.api.dtos.GeneratedArg;
23+
import org.astonbitecode.j4rs.errors.InvocationException;
2224

2325
public class Utils {
2426

@@ -74,7 +76,12 @@ public static String throwableToString(Throwable throwable) {
7476
if (throwable != null) {
7577
StringWriter sw = new StringWriter();
7678
PrintWriter pw = new PrintWriter(sw);
77-
throwable.printStackTrace(pw);
79+
if (throwable != null && throwable instanceof InvocationException
80+
&& throwable.getCause() != null && throwable.getCause() instanceof InvocationTargetException) {
81+
throwable.getCause().getCause().printStackTrace(pw);
82+
} else {
83+
throwable.printStackTrace(pw);
84+
}
7885
return sw.toString();
7986
} else {
8087
return "Cannot create String out of a null Throwable";
110 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)