update crash suggestions.

This commit is contained in:
huanghongxun
2015-07-03 12:50:11 +08:00
parent 07b8c5777a
commit cdb78a31e9
7 changed files with 43 additions and 32 deletions

View File

@@ -124,15 +124,13 @@ public final class Launcher {
minecraftMain.invoke(null, new Object[]{cmds});
} catch (Throwable throwable) {
HMCLog.err("Cought exception!");
final StringWriter trace = new StringWriter();
PrintWriter writer = new PrintWriter(trace);
throwable.printStackTrace(writer);
final String advice = MinecraftCrashAdvicer.getAdvice(throwable);
String trace = StrUtils.getStackTrace(throwable);
final String advice = MinecraftCrashAdvicer.getAdvice(trace);
MessageBox.Show(C.i18n("crash.minecraft") + ": " + advice);
LogWindow.instance.log(C.i18n("crash.minecraft"));
LogWindow.instance.log(advice);
LogWindow.instance.log(trace.toString());
LogWindow.instance.log(trace);
LogWindow.instance.setExit(TrueFunction.instance);
LogWindow.instance.setVisible(true);
}

View File

@@ -16,7 +16,6 @@
*/
package org.jackhuang.hellominecraft.launcher.launch;
import java.util.ConcurrentModificationException;
import org.jackhuang.hellominecraft.C;
/**
@@ -26,32 +25,42 @@ import org.jackhuang.hellominecraft.C;
*/
public final class MinecraftCrashAdvicer {
public static String getAdvice(Throwable t) {
return getAdvice(t, false);
public static String getAdvice(String trace) {
return getAdvice(trace, false);
}
public static String getAdvice(Throwable t, boolean selfCrash) {
if (t.getCause() instanceof UnsupportedClassVersionError) {
public static String getAdvice(String trace, boolean selfCrash) {
/*if (t.getCause() instanceof UnsupportedClassVersionError) {
return C.i18n("crash.advice.UnsupportedClassVersionError");
} else if (t instanceof ConcurrentModificationException) {
return C.i18n("crash.advice.ConcurrentModificationException");
} else if (t instanceof SecurityException) {
return C.i18n("crash.advice.SecurityException");
} else if (t instanceof InvocationTargetException) {
return C.i18n("crash.advice.InvocationTargetException");
} else if (t instanceof NoSuchFieldError || (t.getCause() != null && t.getCause() instanceof NoSuchFieldException)) {
return C.i18n("crash.advice.NoSuchFieldError");
} else if (t instanceof NoClassDefFoundError || (t.getCause() != null && t.getCause() instanceof ClassNotFoundException)) {
} else if (t instanceof NoClassDefFoundError || t instanceof ClassNotFoundException || (t.getCause() != null && t.getCause() instanceof ClassNotFoundException)) {
return C.i18n("crash.advice.ClassNotFondException");
}
if (t.getMessage() != null) {
if (t.getMessage().contains("OpenGL") || t.getMessage().contains("OpenAL")) {
return C.i18n("crash.advice.OpenGL");
}
}
if (t.getCause() != null && t.getCause().getMessage() != null) {
if (t.getCause().getMessage().contains("no lwjgl in java.library.path")) {
return C.i18n("crash.advice.no_lwjgl");
}
}*/
if (trace.contains("LWJGLException")) {
if(trace.contains("Pixel format not accelerated"))
return C.i18n("crash.advice.LWJGLException");
} else if (trace.contains("UnsupportedClassVersionError")) {
return C.i18n("crash.advice.UnsupportedClassVersionError");
} else if (trace.contains("ConcurrentModificationException")) {
return C.i18n("crash.advice.ConcurrentModificationException");
} else if (trace.contains("SecurityException")) {
return C.i18n("crash.advice.SecurityException");
} else if (trace.contains("NoSuchFieldException") || trace.contains("NoSuchFieldError")) {
return C.i18n("crash.advice.NoSuchFieldError");
} else if (trace.contains("NoClassDefFoundError") || trace.contains("ClassNotFoundException")) {
return C.i18n("crash.advice.ClassNotFondException");
} else if (trace.contains("no lwjgl in java.library.path")) {
return C.i18n("crash.advice.no_lwjgl");
} else if (trace.contains("OpenGL") || trace.contains("OpenAL")) {
return C.i18n("crash.advice.OpenGL");
}
return selfCrash ? C.i18n("crash.advice.no") : C.i18n("crash.advice.otherwise");
}

View File

@@ -47,7 +47,7 @@ public class CrashReport implements Thread.UncaughtExceptionHandler {
text += " Time: " + DateFormat.getDateInstance().format(new Date()) + "\n";
text += " Thread: " + t.toString() + "\n";
text += "\n Advice: \n ";
text += MinecraftCrashAdvicer.getAdvice(e, true);
text += MinecraftCrashAdvicer.getAdvice(StrUtils.getStackTrace(e), true);
text += "\n Content: \n ";
text += StrUtils.getStackTrace(e) + "\n\n";
text += "-- System Details --\n";