Catching serial device connection exception

I have a Windows desktop app on Xojo 2025v1.1 and it connects to one or more serial (usb) devices. All works fine until I test the scenario when a device is being used by another app.

The Try..Catch doesn’t pick up the exception at all as in the screenshot below. I initially had Catch e as IOException then modified it to simply Catch but still doesn’t pick it up. This is even there’s a clearly listed IOException in the IDE.

Any ideas please, surely it should catch any exceptions? Thanks

Catch e As IOException

The screenshot shows the location where the error occurs at the moment the error occurs.
If you then proceed a step further in the debugger, your exception handling should be triggered.

1 Like

If you want the debugger to just automatically catch the exception, wrap the try-catch-end try with:

#pragma breakonexceptions False

... code

#pragma breakonexceptions Default
3 Likes

:man_facepalming:
Of course! The debugger breaks on an exception in any case! My bad, I really didn’t consider that. Thanks

1 Like