When Xojo App Closes Without Exception

How do I locate an error in my code if my app just closes and crashes without an exception?


did you put code in the UNHANDLED EXCEPTION event of the APP object?
this doesn’t ALWAYS catch things, but sometimes

here is what I have in most of my apps

  Dim d As New Date
  Dim f As New FolderItem
  f  = SpecialFolder.Desktop.Child(App.ExecutableFile.DisplayName+"_ERRORLOG.txt")
  If f.exists Then f.delete
  Dim t As TextOutputStream
  If t = Nil Then Return False
  t.WriteLine "UnhandledException: " + Introspection.GetType(error).Name + EndOfLine
  t.WriteLine "Current date: " +  d.SQLDateTime + EndOfLine + EndOfLine
  t.WriteLine "Executable Name: " + App.ExecutableFile.DisplayName
  t.WriteLine "Executable Path: " + f.NativePath + EndOfLine
  t.WriteLine "Executable Size: " + Str( App.ExecutableFile.Length )
  t.WriteLine "Executable ModificationDate: " + App.ExecutableFile.ModificationDate.SQLDateTime
  t.WriteLine "Executable CreationDate: " + App.ExecutableFile.CreationDate.SQLDateTime + EndOfLine
  t.WriteLine "Call Stack: " + EndOfLine
  t.WriteLine "Stack: " + EndOfLine + Join( error.Stack, EndOfLine)
  myMsgBox "An error occured "+ Introspection.GetType(error).Name + "^^A error log has been saved under " + EndOfLine + f.NativePath  +"^^App will be closed.",16

I’m locking this thread, since the discussion is duplicated here: