improved crash window
* added request to create a github issue for the crash * added url to create a github issue * url is copyable * removed noisy textmaster
parent
fcca2fd589
commit
ae526cb08a
|
@ -22,8 +22,6 @@ import amidst.mojangapi.file.DotMinecraftDirectoryNotFoundException;
|
|||
|
||||
@NotThreadSafe
|
||||
public class Amidst {
|
||||
private static final String UNCAUGHT_EXCEPTION_ERROR_MESSAGE = "Amidst has encounted an uncaught exception on thread: ";
|
||||
|
||||
@CalledOnlyBy(AmidstThread.STARTUP)
|
||||
public static void main(String args[]) {
|
||||
initUncaughtExceptionHandler();
|
||||
|
@ -34,7 +32,7 @@ public class Amidst {
|
|||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable e) {
|
||||
handleCrash(e, UNCAUGHT_EXCEPTION_ERROR_MESSAGE + thread);
|
||||
handleCrash(e, thread);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -136,12 +134,14 @@ public class Amidst {
|
|||
"Please install Minecraft",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} catch (Exception e) {
|
||||
handleCrash(e, "Amidst crashed!");
|
||||
handleCrash(e, Thread.currentThread());
|
||||
}
|
||||
}
|
||||
|
||||
@CalledByAny
|
||||
private static void handleCrash(Throwable e, String message) {
|
||||
private static void handleCrash(Throwable e, Thread thread) {
|
||||
String message = "Amidst has encounted an uncaught exception on the thread "
|
||||
+ thread;
|
||||
try {
|
||||
Log.crash(e, message);
|
||||
displayCrashWindow(message, Log.getAllMessages());
|
||||
|
|
|
@ -9,6 +9,7 @@ import javax.swing.JFrame;
|
|||
import javax.swing.JLabel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
|
@ -21,13 +22,14 @@ public class CrashWindow {
|
|||
|
||||
public CrashWindow(String message, String logMessages,
|
||||
final Runnable executeOnClose) {
|
||||
frame = new JFrame("Amidst encountered an unexpected error.");
|
||||
frame = new JFrame("Amidst crashed!");
|
||||
frame.getContentPane().setLayout(new MigLayout());
|
||||
frame.add(new JLabel("Amidst has crashed with the following message:"),
|
||||
"growx, pushx, wrap");
|
||||
frame.add(new JLabel(message), "growx, pushx, wrap");
|
||||
frame.add(new JLabel("Please report this bug on:"),
|
||||
"growx, pushx, wrap");
|
||||
frame.add(createReportingTextField(), "growx, pushx, wrap");
|
||||
frame.add(createLogMessagesScrollPane(logMessages), "grow, push");
|
||||
frame.setSize(500, 400);
|
||||
frame.setSize(800, 600);
|
||||
frame.setVisible(true);
|
||||
frame.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
|
@ -38,6 +40,14 @@ public class CrashWindow {
|
|||
});
|
||||
}
|
||||
|
||||
private JTextField createReportingTextField() {
|
||||
JTextField result = new JTextField(
|
||||
"https://github.com/toolbox4minecraft/amidst/issues/new");
|
||||
result.setEditable(false);
|
||||
result.selectAll();
|
||||
return result;
|
||||
}
|
||||
|
||||
private JScrollPane createLogMessagesScrollPane(String logMessages) {
|
||||
JScrollPane result = new JScrollPane(
|
||||
createLogMessagesTextArea(logMessages));
|
||||
|
|
Loading…
Reference in New Issue