I'm trying hard to figure out a way to do proper exception handling using the DeviceClient API to connect to IoT hub.
I've been using the API for a while and still I can't get my head around the design of the callback implementation
public void SetConnectionStatusChangesHandler(ConnectionStatusChangesHandler statusChangesHandler);
forces me to not use any async method inside the handler as I can't propagate any errors outside. A typical use case is fetching all upstream desired properties and upload reported properties after having checked for changes. But any error occuring during these functions (which are all async and therefore force me to have an async void callback) won't be fetched and basically crashes my application. All I can do is logging but that's all. What is the idea behind this design? Is there a workaround?
Thank you for your reply. I'll try to post the relevant passages of my code. Let me know if you need more info.
How can I implement proper error handling here? Is there another option to update device properties?
(Could not reply to your answer directly)
Sorry, for some reason I cannot reply here, so I wrote an answer.
Now worries we are looking into this.
Sign in to comment