scratchfoundation / scratch-link

Device interoperability layer for Windows and MacOS
BSD 3-Clause "New" or "Revised" License
104 stars 84 forks source link

Avoid double-fault when SendErrorNotification fails #95

Closed cwillisf closed 5 years ago

cwillisf commented 5 years ago

This change resolves #93.

Send SendErrorNotification function is meant to inform the client of a server-side error. That's great... unless the error is related to the WebSocket closing. In that case, sending the notification will fail. The WebSocket library we're using reports that failure by throwing an exception. Since the common case for calling SendErrorNotification is in response to an exception, we probably don't need or want to report this secondary exception; this code instead suppresses it after printing some debug text.

The try/try/finally/catch structure is a little odd but I wanted to emphasize that the inner try/finally is about thread safety and should be as small as possible, whereas the outer try/catch is about error reporting and can cover the serialization calls as well. Please let me know if you have strong opinions about that.

evhan55 commented 5 years ago

Hello! I wanted to help test this today but I don't have access to a Windows machine. We have ordered two Dell laptops in the lab today and I can help test as soon as I get one. But, let me know if there are Mac OS tests related to this that I can do in the meantime.