RickStrahl / wwDotnetBridge

.NET Interop for Visual FoxPro made easy
http://west-wind.com/wwDotnetBridge.aspx
MIT License
74 stars 35 forks source link

Notify application of handler exceptions #16

Closed breyed closed 2 years ago

breyed commented 6 years ago

When an exception occurs in an async or event handler, capture the exception, and make it available to the application. For example, an OnCompleted handler for InvokeMethodAysnc call might throw an exception. Or an OnSomeEvent handler for an SubscribeToEvents call might throw an exception.

One way to address this is to add an optional parameter to GetwwDotnetBridge, which takes an object with a function called OnDotnetBridgeError, which will be called for each error. If the optional parameter isn't passed or OnDotnetBridgeError can't be called, the bridge will output the error to the console as an alternative. Such an approach would allow production apps to capture the error for diagnostics, with reasonable fallback notification for scenarios where setting up an error notification handler is overkill.

Split from #13.