Problem
The project's own rule is specific exception types only, and an empty catch at least logs at Debug. Today, outside the three in App.xaml.cs, each of which says why it is broad, the app has 39 catch (Exception …) blocks with no when filter, and 17 typed catches with an empty body. Some are there on purpose and say so (LibreHardwareMonitor and NvAPI can throw anything from native code, and ViewModelBase.InitializeAsync is the last-resort net), but nothing tells those apart from the rest, and no test stops a new one.
- Unfiltered
catch (Exception): Services/EtwBandwidthSource.cs, GamingProfileService.cs (3), PingMonitorService.cs, ResourceHistoryService.cs (3), TemperatureService.cs (5), ThemeService.cs (2), TrayIconService.cs (2), UpdateService.cs, ViewModels/AudioMixerViewModel.cs (2), BandwidthMonitorViewModel.cs, BulkInstallerViewModel.cs (3), DashboardViewModel.cs (8), DnsHostsViewModel.cs (4), ProcessManagerViewModel.cs, StandbyMemoryViewModel.cs, ViewModelBase.cs.
- Empty typed catches:
Helpers/AtomicFile.cs, Helpers/ExplorerShell.cs, Services/AudioMixerService.cs (2), AudioPolicyConfig.cs, GamingProfileService.cs, LargeFileScanner.cs (6), PowerShellRunner.cs (2), ServiceManagerService.cs, ViewModels/DnsHostsViewModel.cs (2).
Proposed solution
Go through each: narrow it to the types the call can throw, or keep it broad with a when filter or a one-line reason where the code wraps native or third-party code that can throw anything. Empty catches log at Debug. Then add an ArchitectureTests guard that fails on a new unfiltered catch (Exception) or empty catch, with the reviewed ones listed by file and reason, so the list only shrinks.
Affected tab
Cross-app
Problem
The project's own rule is specific exception types only, and an empty catch at least logs at Debug. Today, outside the three in
App.xaml.cs, each of which says why it is broad, the app has 39catch (Exception …)blocks with nowhenfilter, and 17 typed catches with an empty body. Some are there on purpose and say so (LibreHardwareMonitor and NvAPI can throw anything from native code, andViewModelBase.InitializeAsyncis the last-resort net), but nothing tells those apart from the rest, and no test stops a new one.catch (Exception):Services/EtwBandwidthSource.cs,GamingProfileService.cs(3),PingMonitorService.cs,ResourceHistoryService.cs(3),TemperatureService.cs(5),ThemeService.cs(2),TrayIconService.cs(2),UpdateService.cs,ViewModels/AudioMixerViewModel.cs(2),BandwidthMonitorViewModel.cs,BulkInstallerViewModel.cs(3),DashboardViewModel.cs(8),DnsHostsViewModel.cs(4),ProcessManagerViewModel.cs,StandbyMemoryViewModel.cs,ViewModelBase.cs.Helpers/AtomicFile.cs,Helpers/ExplorerShell.cs,Services/AudioMixerService.cs(2),AudioPolicyConfig.cs,GamingProfileService.cs,LargeFileScanner.cs(6),PowerShellRunner.cs(2),ServiceManagerService.cs,ViewModels/DnsHostsViewModel.cs(2).Proposed solution
Go through each: narrow it to the types the call can throw, or keep it broad with a
whenfilter or a one-line reason where the code wraps native or third-party code that can throw anything. Empty catches log at Debug. Then add anArchitectureTestsguard that fails on a new unfilteredcatch (Exception)or empty catch, with the reviewed ones listed by file and reason, so the list only shrinks.Affected tab
Cross-app