March 2018
Intermediate to advanced
192 pages
4h 4m
English
Now that we have an IAnalyticsService property in all of our ViewModels, we can update all of our try/catch blocks to pass exceptions to App Center. For example, in MainViewModel, we have a try/finally block in the LoadEntries method that is currently not catching exceptions.
Update this try/finally block with a catch block and then pass any caught Exception off to the analytics service via the TrackError method:
void LoadEntries(){ if (IsBusy) { return; } IsBusy = true; try { // ... } catch (Exception e) { AnalyticsService.TrackError(e, new Dictionary<string, string> { {"Method", "MainViewModel.LoadEntries()"} }); } finally { IsBusy = false; }}