mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
truncate stack overflow error traces so the resulting messages aren't too long to post
This commit is contained in:
@@ -65,6 +65,8 @@ import forge.properties.NewConstants;
|
|||||||
* @version V1.0 02.08.2009
|
* @version V1.0 02.08.2009
|
||||||
*/
|
*/
|
||||||
public class BugReporter {
|
public class BugReporter {
|
||||||
|
private static final int _STACK_OVERFLOW_MAX_MESSAGE_LEN = 16 * 1024;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows exception information in a format ready to post to the forum as a crash report. Uses the exception's message
|
* Shows exception information in a format ready to post to the forum as a crash report. Uses the exception's message
|
||||||
* as the reason if message is null.
|
* as the reason if message is null.
|
||||||
@@ -90,7 +92,17 @@ public class BugReporter {
|
|||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
ex.printStackTrace(pw);
|
ex.printStackTrace(pw);
|
||||||
sb.append(sw.toString());
|
|
||||||
|
String swStr = sw.toString();
|
||||||
|
if (ex instanceof StackOverflowError &&
|
||||||
|
_STACK_OVERFLOW_MAX_MESSAGE_LEN <= swStr.length()) {
|
||||||
|
// most likely a cycle. only take first portion so the message
|
||||||
|
// doesn't grow too large to post
|
||||||
|
sb.append(swStr, 0, _STACK_OVERFLOW_MAX_MESSAGE_LEN);
|
||||||
|
sb.append("\n... (truncated)");
|
||||||
|
} else {
|
||||||
|
sb.append(swStr);
|
||||||
|
}
|
||||||
|
|
||||||
_buildSpoilerFooter(sb);
|
_buildSpoilerFooter(sb);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user