Unhandled Exception Issues

[quote=352198:@Jon Ogden]You mean this:

If error <> Nil Then
  Dim type As String = Introspection.GetType(error).Name
  MsgBox(type + EndOfLine + EndOfLine + Join(error.Stack, EndOfLine))
End If

I just pulled it out of the LR. But one problem, it doesn’t return True so the app will still fail! :slight_smile:

I have based my code on that but your comments are spot on examples of the defensive coding needed.[/quote]

Mean that yes. Then you add your simplest form of logging and perhaps uploading, while return true/false based on your code requirements

One thing you can do is have a global array of error messages Let’s say a Custom LogItem class. Then in your base code you handle the exceptions and if catched, add item to the log array.

In App.UnhandledException you write the log array items to a file and return true.

Ok, so this:

If error IsA OutOfMemoryException Then Return True End If

Will likely never be called. Once you’ve reached an out of memory situation, just about the only thing your app can do is fall over.

This:

Dim bs as BinaryStream = BinaryStream.Open(f)

Will throw an IOException if the file can’t be created or another error occurs. Without an exception handler that’ll cause problems.

[quote=352263:@Greg O’Lone]Ok, so this:

If error IsA OutOfMemoryException Then Return True End If

Will likely never be called. Once you’ve reached an out of memory situation, just about the only thing your app can do is fall over.
[/quote]

OK. There are possible scenarios were the app can be downloading some significant amount of image data. I’ve had reports from people on it in the past. However, since moving to 64 bit, this has not happened. So I wasn’t sure if having this would do anything or not.

[quote]

This:

Dim bs as BinaryStream = BinaryStream.Open(f)

Will throw an IOException if the file can’t be created or another error occurs. Without an exception handler that’ll cause problems.[/quote]

Yes, I’ve fixed that. Others pointed that out as well!

Thanks.

Just because your app is 64-bit, doesn’t mean that it can’t run out of RAM. On a machine with > 4GB OF memory, and running nothing else, it’ll just take longer.

Remember all 64-bit does for you is remove the 4GB (3.5 on Windows) limit of the 32-bit pointers. Increased to something like 16TB, and at the rate we’re going that should be summer 2020. :stuck_out_tongue: