Extract shared RollbackQuietlyAsync helper into DapperRepository base class

Avoids duplicating the transaction-rollback-swallowing logic in every repository that needs it, starting with BreweryRepository.
This commit is contained in:
Aaron Po
2026-08-28 00:32:13 -04:00
parent 3d4d448fe6
commit db07d87f97
4 changed files with 39 additions and 16 deletions

View File

@@ -441,22 +441,6 @@ public class BreweryRepository(ISqlConnectionFactory connectionFactory)
}
}
/// <summary>
/// Rolls back <paramref name="transaction" />, swallowing any exception the rollback itself
/// raises (for example when the provider has already completed the transaction after a
/// connection failure) so the exception that triggered the rollback is what propagates.
/// </summary>
private static async Task RollbackQuietlyAsync(DbTransaction transaction)
{
try
{
await transaction.RollbackAsync();
}
catch
{
// Ignore: the original exception (rethrown by the caller) is what matters here.
}
}
/// <summary>
/// Composes a joined row's <see cref="BreweryPost" />, <see cref="BreweryPostLocation" />,