C
C#12mo ago
Florian Voß

❔ Exception hadnling in WPF App

I have an app that is being used as a TicketSystem. It monitors incoming calls and tickets for our Agents and lets the agents interact with those. The calls are being queried from DB using Ado.Net Types (SqlConnection, SqlCommand) The tickets are being queried from external api using HttpClient Currently When there is an exception trying to get the calls or trying to get the tickets I display "Error, data couldn't be loaded" where I would otherwise display the respective DataGrid using a regular catch(Exception ex){} block One common scenario that made our App crash before we had this catch block was when the Agent is in his home office and doesn't have his VPN turned on to access company ressources. Now I wonder whether I can catch a more specific exception, so that I can render "Make sure your VPN is turned on to access the company ressources" or smth like that.
9 Replies
Pobiega
Pobiega12mo ago
Sure, look at the actual runtime type of the exception caught then add another catch for that type, before the Exception one
Florian Voß
Florian Voß12mo ago
I sadly don't have access to it. We don't have logging implemented yet, and the user who faced this issue doesn't remember any detail information on the Exeption
Pobiega
Pobiega12mo ago
can you simulate it yourself somehow?
Florian Voß
Florian Voß12mo ago
will try thx
Pobiega
Pobiega12mo ago
also, you really should add logging 😄
Florian Voß
Florian Voß12mo ago
ye I will 😄 its pretty fresh project
Pobiega
Pobiega12mo ago
Serilog ❤️
Florian Voß
Florian Voß12mo ago
definetly into Azure App Insights 😊
Accord
Accord12mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.