From 1b080ac87ea4e81b705a7fbb291ab8e724b8763f Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sat, 5 Nov 2022 21:09:23 -0400 Subject: [PATCH] Include the full stack trace in exception message The format of this error message used to look like: ```java Expected number (0) of Non-OK status objects in log differs from actual (1). Error while parsing /projC_testTripleDownwardV/h3.h. java.lang.reflect.InvocationTargetException Caused by: java.lang.reflect.InvocationTargetException Caused by: java.lang.AssertionError: Need to hold a write lock to clear result caches ``` and it was hard to impossible to identify what the cause is. The hope is that capturing this fuller stack trace into the log will make it easier to identify the problem. Part of #117 --- .../cdt/core/testplugin/util/LogMonitoring.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/LogMonitoring.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/LogMonitoring.java index 88b630230d3..ddc301a0943 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/LogMonitoring.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/LogMonitoring.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.core.testplugin.util; +import java.io.PrintWriter; +import java.io.StringWriter; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -72,9 +74,15 @@ class LogMonitoring { cause = cause != null ? cause : t; if (t != null) { msg.append(t.getMessage() != null ? t.getMessage() : t.getClass().getCanonicalName()); + msg.append("\nStack Trace\n"); + StringWriter writer = new StringWriter(); + PrintWriter out = new PrintWriter(writer); + t.printStackTrace(out); + msg.append(writer.toString()); + } - msg.append("\n"); + msg.append("\n\n"); } } }