Skip to content

Commit aeaf341

Browse files
committed
chore(resharper): drop redundant namespace qualifiers in catch filters
ReSharper RedundantNameQualifier flagged all 45 occurrences of Microsoft.EntityFrameworkCore.DbUpdateException and Microsoft.Data.SqlClient.SqlException in the when-filtered catches introduced by codeql/5. Replaced with the unqualified type names; 'using Microsoft.Data.SqlClient;' added to the 7 files that didn't already have it.
1 parent c269ad7 commit aeaf341

8 files changed

Lines changed: 46 additions & 39 deletions

File tree

web/Areas/ClinicalScheduler/Services/InstructorScheduleService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Microsoft.Data.SqlClient;
12
using Microsoft.EntityFrameworkCore;
23
using Viper.Classes.SQLContext;
34
using Viper.Models.CTS;
@@ -104,7 +105,7 @@ public async Task<List<InstructorSchedule>> GetInstructorScheduleAsync(
104105
_logger.LogInformation("Found {Count} instructor schedules", schedules.Count);
105106
return schedules;
106107
}
107-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
108+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
108109
{
109110
_logger.LogError(ex, "Error retrieving instructor schedules");
110111
throw new InvalidOperationException("Failed to retrieve instructor schedules", ex);

web/Areas/ClinicalScheduler/Services/PersonService.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public PersonService(ILogger<PersonService> logger, ClinicalSchedulerContext con
8181

8282
return person;
8383
}
84-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
84+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
8585
{
8686
_logger.LogError(ex, "Error retrieving person data for MothraId: {MothraId}", LogSanitizer.SanitizeId(mothraId));
8787
throw new InvalidOperationException($"Failed to retrieve person data for MothraId {LogSanitizer.SanitizeId(mothraId)}", ex);
@@ -139,7 +139,7 @@ public async Task<List<ClinicianYearSummary>> GetCliniciansByYearAsync(int year,
139139
_logger.LogInformation("Found {ClinicianCount} clinicians for year {Year} with person names from vPerson view", clinicians.Count, year);
140140
return clinicians;
141141
}
142-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
142+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
143143
{
144144
_logger.LogError(ex, "Error retrieving clinicians for year: {Year}", year);
145145
throw new InvalidOperationException($"Failed to retrieve clinicians for grad year {year}. Check database connectivity and view permissions.", ex);
@@ -209,7 +209,7 @@ public async Task<List<ClinicianSummary>> GetCliniciansByGradYearRangeAsync(int
209209
_logger.LogError(ex, "Database error retrieving clinicians for grad year range {StartYear}-{EndYear}", LogSanitizer.SanitizeYear(startGradYear), LogSanitizer.SanitizeYear(endGradYear));
210210
throw new InvalidOperationException($"Database error retrieving clinicians for grad year range {LogSanitizer.SanitizeYear(startGradYear)}-{LogSanitizer.SanitizeYear(endGradYear)}", ex);
211211
}
212-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
212+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
213213
{
214214
_logger.LogError(ex, "Error retrieving clinicians for grad year range {StartYear}-{EndYear}", LogSanitizer.SanitizeYear(startGradYear), LogSanitizer.SanitizeYear(endGradYear));
215215
throw new InvalidOperationException($"Failed to retrieve clinicians for grad year range {LogSanitizer.SanitizeYear(startGradYear)}-{LogSanitizer.SanitizeYear(endGradYear)}", ex);
@@ -240,7 +240,7 @@ public async Task<List<string>> GetAllMothraIdsAsync(CancellationToken cancellat
240240
_logger.LogInformation("Found {Count} unique MothraIds in Clinical Scheduler data", mothraIds.Count);
241241
return mothraIds;
242242
}
243-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
243+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
244244
{
245245
_logger.LogError(ex, "Error retrieving unique MothraIds");
246246
throw new InvalidOperationException("Failed to retrieve unique MothraIds from database", ex);
@@ -277,7 +277,7 @@ public async Task<List<ClinicianSummary>> GetAllActiveEmployeeAffiliatesAsync(Ca
277277
_logger.LogDebug("Found {Count} active employee affiliates from AAUD", allAffiliates.Count);
278278
return allAffiliates;
279279
}
280-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
280+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
281281
{
282282
_logger.LogError(ex, "Error retrieving active employee affiliates from AAUD");
283283
throw new InvalidOperationException("Failed to retrieve active employee affiliates from AAUD database", ex);
@@ -325,7 +325,7 @@ public async Task<List<ClinicianSummary>> GetAllActiveEmployeeAffiliatesAsync(Ca
325325

326326
return clinician;
327327
}
328-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
328+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
329329
{
330330
_logger.LogError(ex, "Error retrieving clinician data for MothraId: {MothraId} from AAUD", LogSanitizer.SanitizeId(mothraId));
331331
throw new InvalidOperationException($"Failed to retrieve clinician data for MothraId {LogSanitizer.SanitizeId(mothraId)} from AAUD", ex);

web/Areas/ClinicalScheduler/Services/RotationService.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Microsoft.Data.SqlClient;
12
using Microsoft.EntityFrameworkCore;
23
using Viper.Areas.ClinicalScheduler.Extensions;
34
using Viper.Areas.ClinicalScheduler.Models.DTOs.Responses;
@@ -45,7 +46,7 @@ public async Task<List<RotationDto>> GetRotationsAsync(CancellationToken cancell
4546
rotations.Count);
4647
return rotations.Select(r => r.ToDto()).ToList();
4748
}
48-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
49+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
4950
{
5051
_logger.LogError(ex, "Error retrieving rotations from Clinical Scheduler");
5152
throw new InvalidOperationException("Failed to retrieve rotations from Clinical Scheduler database", ex);
@@ -82,7 +83,7 @@ public async Task<List<RotationDto>> GetRotationsAsync(CancellationToken cancell
8283

8384
return rotation?.ToDto();
8485
}
85-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
86+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
8687
{
8788
_logger.LogError(ex, "Error retrieving rotation by ID: {RotationId}", rotationId);
8889
throw new InvalidOperationException($"Failed to retrieve rotation with ID {rotationId}", ex);
@@ -124,7 +125,7 @@ public async Task<List<Rotation>> GetRotationsByCourseAsync(string courseNumber,
124125

125126
return rotations;
126127
}
127-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
128+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
128129
{
129130
_logger.LogError(ex, "Error retrieving rotations by course - CourseNumber: {CourseNumber}, SubjectCode: {SubjectCode}",
130131
courseNumber, subjectCode);
@@ -154,7 +155,7 @@ public async Task<List<RotationDto>> GetRotationsByServiceAsync(int serviceId, C
154155
_logger.LogInformation("Retrieved {Count} rotations for service ID: {ServiceId}", rotations.Count, serviceId);
155156
return rotations.Select(r => r.ToDto()).ToList();
156157
}
157-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
158+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
158159
{
159160
_logger.LogError(ex, "Error retrieving rotations by service ID: {ServiceId}", serviceId);
160161
throw new InvalidOperationException($"Failed to retrieve rotations for service ID {serviceId}", ex);
@@ -180,7 +181,7 @@ public async Task<List<ServiceDto>> GetServicesAsync(CancellationToken cancellat
180181
_logger.LogInformation("Retrieved {Count} services from Clinical Scheduler", services.Count);
181182
return services.Select(s => s.ToDto()).ToList();
182183
}
183-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
184+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
184185
{
185186
_logger.LogError(ex, "Error retrieving services from Clinical Scheduler");
186187
throw new InvalidOperationException("Failed to retrieve services from Clinical Scheduler database", ex);
@@ -215,7 +216,7 @@ public async Task<List<ServiceDto>> GetServicesAsync(CancellationToken cancellat
215216

216217
return service?.ToDto();
217218
}
218-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
219+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
219220
{
220221
_logger.LogError(ex, "Error retrieving service by ID: {ServiceId}", serviceId);
221222
throw new InvalidOperationException($"Failed to retrieve service with ID {serviceId}", ex);
@@ -265,7 +266,7 @@ public async Task<List<InstructorSchedule>> GetInstructorSchedulesByRotationAsyn
265266

266267
return schedules;
267268
}
268-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
269+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
269270
{
270271
_logger.LogError(ex, "Error retrieving instructor schedules for rotation ID: {RotationId}", rotationId);
271272
throw new InvalidOperationException($"Failed to retrieve instructor schedules for rotation ID {rotationId}", ex);

web/Areas/ClinicalScheduler/Services/ScheduleAuditService.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Microsoft.Data.SqlClient;
12
using Microsoft.EntityFrameworkCore;
23
using Viper.Classes.SQLContext;
34
using Viper.Models.ClinicalScheduler;
@@ -114,7 +115,7 @@ public async Task<List<ScheduleAudit>> GetInstructorScheduleAuditHistoryAsync(
114115
.OrderByDescending(a => a.TimeStamp)
115116
.ToListAsync(cancellationToken);
116117
}
117-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
118+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
118119
{
119120
_logger.LogError(ex, "Error retrieving audit history for instructor schedule {ScheduleId}", instructorScheduleId);
120121
throw new InvalidOperationException($"Failed to retrieve audit history for instructor schedule {instructorScheduleId}. Please try again or contact support if the problem persists.", ex);
@@ -134,7 +135,7 @@ public async Task<List<ScheduleAudit>> GetRotationWeekAuditHistoryAsync(
134135
.OrderByDescending(a => a.TimeStamp)
135136
.ToListAsync(cancellationToken);
136137
}
137-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
138+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
138139
{
139140
_logger.LogError(ex, "Error retrieving audit history for rotation {RotationId}, week {WeekId}", rotationId, weekId);
140141
throw new InvalidOperationException($"Failed to retrieve audit history for rotation {rotationId}, week {weekId}. Please try again or contact support if the problem persists.", ex);
@@ -179,7 +180,7 @@ private async Task<ScheduleAudit> CreateAuditEntryAsync(
179180

180181
return auditEntry;
181182
}
182-
catch (Exception ex) when (ex is Microsoft.EntityFrameworkCore.DbUpdateException or Microsoft.Data.SqlClient.SqlException or InvalidOperationException or OperationCanceledException)
183+
catch (Exception ex) when (ex is DbUpdateException or SqlException or InvalidOperationException or OperationCanceledException)
183184
{
184185
_logger.LogError(ex, "Error creating audit entry for action {Action}, {MothraId} on rotation {RotationId}, week {WeekId}",
185186
action, LogSanitizer.SanitizeId(mothraId), rotationId, weekId);

0 commit comments

Comments
 (0)