GWT.setUncaughtExceptionHandler
GWT設(shè)置UncaughtExceptionHandler 以捕獲為捕捉的異常,這gwt在host mode編譯后的JavaScript如果出現(xiàn)錯(cuò)誤,No errors in Hosted Mode and Compiled localy, but deployed to tomcat yields in errors
這是惱人,加上UncaughtExceptionHandler起碼有一絲線索 |
GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
public void onUncaughtException(Throwable throwable) {
String text = "Uncaught exception: ";
while (throwable != null) {
StackTraceElement[] stackTraceElements = throwable
.getStackTrace();
text += throwable.toString() + "\n";
for (int i = 0; i < stackTraceElements.length; i++) {
text += " at " + stackTraceElements[i] + "\n";
}
throwable = throwable.getCause();
if (throwable != null) {
text += "Caused by: ";
}
}
System.err.print(text);
text = text.replaceAll(" ", " ");
Window.alert("系統(tǒng)錯(cuò)誤:"+text);
}
});
public void onUncaughtException(Throwable throwable) {
String text = "Uncaught exception: ";
while (throwable != null) {
StackTraceElement[] stackTraceElements = throwable
.getStackTrace();
text += throwable.toString() + "\n";
for (int i = 0; i < stackTraceElements.length; i++) {
text += " at " + stackTraceElements[i] + "\n";
}
throwable = throwable.getCause();
if (throwable != null) {
text += "Caused by: ";
}
}
System.err.print(text);
text = text.replaceAll(" ", " ");
Window.alert("系統(tǒng)錯(cuò)誤:"+text);
}
});
posted on 2010-05-19 10:18 豬 閱讀(369) 評(píng)論(0) 編輯 收藏 所屬分類: gwt