Skip to content

Commit

Permalink
Include the full stack trace in exception message
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jonahgraham committed Nov 7, 2022
1 parent 8c6f501 commit 1b080ac
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -72,9 +74,15 @@ void stop(int expectedLoggedNonOK) {
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");
}
}
}
Expand Down

0 comments on commit 1b080ac

Please sign in to comment.