'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
LogError(Error.Message, StackTrace)
Return True
End Sub
Sub LogError(strErrorMsg As String, strStackTrace As String)
Dim arrError(3) As Object
arrError(0) = DateTime.Now / 1000 'as we need seconds, not milli-seconds
arrError(1) = GetErrorSubFromStackTrace(strStackTrace)
arrError(2) = strErrorMsg
CallSub2(B4XPages.GetManager.MainPage, "LogAppError", arrError)
End Sub
Sub GetErrorSubFromStackTrace(strStackTrace As String) As String
Dim iPos1 As Int
Dim iPos2 As Int
iPos1 = strStackTrace.IndexOf(Enums.strPackageName) + Enums.strPackageName.Length + 1
iPos2 = strStackTrace.IndexOf2("(", iPos1)
Return strStackTrace.SubString2(iPos1, iPos2).Replace("_", "")
End Sub