I have tried a little test:
Which gives in the logs:
So the code is reaching the Log("After sleep") line as I hoped.
BUT with the sub return type set as ResumableSub, the app does not close (which it should when returning True in Application_Error).
Is there any way that the Application_Error sub can work correctly as a Resumable Sub?
B4X:
'Return true to allow the default exceptions handler to handle the uncaught exception.
'https://www.b4x.com/android/forum/threads/unhandled-exceptions.77506/#content
Sub Application_Error (Error As Exception, StackTrace As String) As ResumableSub
Log("Application_Error: " & CRLF & Error)
Sleep(500)
Log("After sleep")
Return True
End Sub
Private Sub Button1_Click
DateTime.DateParse("ghkglk")
End Sub
Which gives in the logs:
B4X:
Application_Error:
(ParseException) java.text.ParseException: Unparseable date: "ghkglk"
java.lang.RuntimeException: java.lang.ClassCastException: class b4j.example2.main$ResumableSub_Application_Error cannot be cast to class java.lang.Boolean (b4j.example2.main$ResumableSub_Application_Error is in unnamed module of loader 'app'; java.lang.Boolean is in module java.base of loader 'bootstrap')
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:131)
at anywheresoftware.b4a.BA$1.run(BA.java:236)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ClassCastException: class b4j.example2.main$ResumableSub_Application_Error cannot be cast to class java.lang.Boolean (b4j.example2.main$ResumableSub_Application_Error is in unnamed module of loader 'app'; java.lang.Boolean is in module java.base of loader 'bootstrap')
at anywheresoftware.b4a.BA.handleUncaughtException(BA.java:184)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:128)
... 8 more
After sleep
So the code is reaching the Log("After sleep") line as I hoped.
BUT with the sub return type set as ResumableSub, the app does not close (which it should when returning True in Application_Error).
Is there any way that the Application_Error sub can work correctly as a Resumable Sub?