Skip to content

Commit 17737e1

Browse files
Potential fix for code scanning alert no. 18: Generic catch clause
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 81ffc96 commit 17737e1

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

PhantomDave.BankTracking.Api/Services/FileImportService.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,20 @@ public IEnumerable<FinanceRecord> FromParsedData(int accountId, ParsedFileData p
287287

288288
records.Add(record);
289289
}
290-
catch (Exception ex)
290+
catch (FormatException ex)
291291
{
292292
failedCount++;
293-
_logger.LogWarning(ex, "Failed to parse row {RowIndex} during import", records.Count + failedCount);
293+
_logger.LogWarning(ex, "Failed to parse row {RowIndex} due to format error during import", records.Count + failedCount);
294+
}
295+
catch (InvalidCastException ex)
296+
{
297+
failedCount++;
298+
_logger.LogWarning(ex, "Failed to parse row {RowIndex} due to invalid cast during import", records.Count + failedCount);
299+
}
300+
catch (ArgumentException ex)
301+
{
302+
failedCount++;
303+
_logger.LogWarning(ex, "Failed to parse row {RowIndex} due to argument error during import", records.Count + failedCount);
294304
}
295305
_logger.LogDebug("Processed {ProcessedRows} / {TotalRows}, Failed: {FailedRows}",
296306
records.Count + failedCount, parsedData.Rows.Count, failedCount);

0 commit comments

Comments
 (0)