[editor only] What if it never shut down after a crash?

This commit is contained in:
fgnm
2024-01-28 22:57:34 +01:00
parent 96babdc347
commit 5aece5a8d3
5 changed files with 35 additions and 5 deletions
+1 -1
View File
@@ -7,4 +7,4 @@ typingLabelVersion = 1.3.0
shapedrawerVersion = 2.5.0
talosVersion = 1.5.0-SNAPSHOT
gdxTinyVGVersion=7a8927633e
pureMvcVersion=1.0.2
pureMvcVersion=1.0.3-SNAPSHOT
@@ -27,10 +27,20 @@ public class CustomExceptionHandler implements UncaughtExceptionHandler {
writeToFile(stacktrace);
printWriter.close();
showErrorDialog(stacktrace);
showErrorDialog(t, stacktrace);
}
public static void showErrorDialog(String stacktrace) {
public static void showErrorDialog(Throwable e) {
final Writer result = new StringWriter();
final PrintWriter printWriter = new PrintWriter(result);
e.printStackTrace(printWriter);
e.printStackTrace();
String stacktrace = result.toString();
showErrorDialog(null, stacktrace);
}
public static void showErrorDialog(Thread t, String stacktrace) {
File localPath = new File(HyperLap2DUtils.getRootPath()
+ File.separator + "crash" + File.separator + "java-hyperlog.txt");
stacktrace = stacktrace.replace("<", "");
@@ -44,7 +54,8 @@ public class CustomExceptionHandler implements UncaughtExceptionHandler {
+ "\n\n System: " + SystemUtils.OS_NAME + " " + SystemUtils.OS_VERSION + " (HyperLap2D v" + AppConfig.getInstance().versionString + ")"
+ "\n\n" + stacktrace,
"ok", "error", true);
System.exit(-1);
if (t != null)
System.exit(-1);
}
private void writeToFile(String stacktrace) {
@@ -0,0 +1,18 @@
package games.rednblack.editor;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
public class FacadeExceptionHandler implements Thread.UncaughtExceptionHandler {
@Override
public void uncaughtException(Thread t, Throwable e) {
final Writer result = new StringWriter();
final PrintWriter printWriter = new PrintWriter(result);
e.printStackTrace(printWriter);
String stacktrace = result.toString();
CustomExceptionHandler.showErrorDialog(null, stacktrace);
}
}
@@ -28,6 +28,7 @@ public class Main {
}
Thread.currentThread().setUncaughtExceptionHandler(new CustomExceptionHandler());
Facade.getInstance().setUncaughtExceptionHandler(new FacadeExceptionHandler());
//Increase default lwjgl stack size
System.setProperty("org.lwjgl.system.stackSize", "256");
@@ -58,7 +58,7 @@ public class SettingsManager extends Proxy {
e.printStackTrace(printWriter);
e.printStackTrace();
String stacktrace = result.toString();
CustomExceptionHandler.showErrorDialog(stacktrace);
CustomExceptionHandler.showErrorDialog(null, stacktrace);
}
}