B4A has this sub in the starter that is executed on all errors.
B4X:
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
It would be nice to do this in b4i. I find discovering where crashes on production apps are happening on iOS to be quite difficult (even with crash reporting). It would be nice to add the actual line of b4x code to the crash report rather than the underlying Objective C.
I recommend you to use this framework to track crashes: KSCrash - simple and powerful crash reports framework
The underlying error handling in Objective C is limited compared to Android / java (I'm not sure whether this is true with Swift as well) and it makes it more or less impossible to add a global error handler.
I am using KSCrash, but it is still difficult to figure out where the crash happens. I am trying to figure out an way to log the last line of code that executed. It works with a key value store, but it hurts performance too much. Writing it to a text file is better, but still noticable.