Codenameone 代码名One EasyThread.addGlobalErrorListener用法
我不知道该怎么用 让我们转到Codenameone 代码名One EasyThread.addGlobalErrorListener用法,codenameone,Codenameone,我不知道该怎么用 让我们转到init()中的我的代码: 测试EDT的代码: CN.callSerially(() -> { throw new IllegalStateException("Example of IllegalStateException in EDT"); }) 要测试EasyThread的代码: thread.run(() -> { throw new IllegalStateException("
init()
中的我的代码:
测试EDT的代码:
CN.callSerially(() -> {
throw new IllegalStateException("Example of IllegalStateException in EDT");
})
要测试EasyThread的代码:
thread.run(() -> {
throw new IllegalStateException("Example of IllegalStateException in EasyThread");
});
您可以猜到,Server.sendLogAsync()
是我自己的Log.sendLogAsync()
实现。此外,我禁用了崩溃保护,因为我想在发生非托管异常时强制测试人员终止应用程序
我的问题是:
EasyThread t
和callback
作为EasyThread.ErrorListener
的方法onError(EasyThread t,t callback,Throwable error)
的参数有什么用途?在这种情况下,T
是什么感谢您的澄清处理代码中的线程名称不正确,您应该始终打印出EDT:
// Custom EasyThread error handling
EasyThread.addGlobalErrorListener((t, c, e) -> {
String threadName = Thread.currentThread().getName();
CN.callSerially(() -> {
Log.p("\n\n--- Easy Thread CRASH REPORT ---\n", Log.ERROR);
Log.p("Thead name: " + threadName);
if(e != null) {
Log.e(e);
}
Server.sendLogAsync();
Dialog.show("EDT Exception", "Please be patient, report the following ERROR to the developers and then kill the app:\n\n" + e.getMessage(), null, null);
});
});
模拟器的错误很奇怪,我很想知道在这种情况下会发生什么。如果这在调试器中是可复制的,则可能很容易跟踪
提供对触发错误的线程池的直接引用EasyThread
- 回调本质上是
或我们正在运行的类似接口,例如Runnable
。因此RunnableWithResult
指示接口的类型。你可以让事情变得笼统T
// Custom EasyThread error handling
EasyThread.addGlobalErrorListener((t, c, e) -> {
String threadName = Thread.currentThread().getName();
CN.callSerially(() -> {
Log.p("\n\n--- Easy Thread CRASH REPORT ---\n", Log.ERROR);
Log.p("Thead name: " + threadName);
if(e != null) {
Log.e(e);
}
Server.sendLogAsync();
Dialog.show("EDT Exception", "Please be patient, report the following ERROR to the developers and then kill the app:\n\n" + e.getMessage(), null, null);
});
});