1
0
mirror of https://github.com/bitwarden/server synced 2026-01-15 23:13:56 +00:00

Catch general exception for all db types (#6846)

* Switch `SqlException` to `DbException`

Co-authored-by: rkac-bw <148072202+rkac-bw@users.noreply.github.com>

* Fix CA2253

---------

Co-authored-by: rkac-bw <148072202+rkac-bw@users.noreply.github.com>
This commit is contained in:
Justin Baur
2026-01-14 16:27:39 -05:00
committed by GitHub
parent fa845a4753
commit 584af2ee3f

View File

@@ -1,5 +1,5 @@
using Bit.Core.Utilities;
using Microsoft.Data.SqlClient;
using System.Data.Common;
using Bit.Core.Utilities;
namespace Bit.Admin.HostedServices;
@@ -30,7 +30,7 @@ public class DatabaseMigrationHostedService : IHostedService, IDisposable
// TODO: Maybe flip a flag somewhere to indicate migration is complete??
break;
}
catch (SqlException e)
catch (DbException e)
{
if (i >= maxMigrationAttempts)
{
@@ -40,7 +40,7 @@ public class DatabaseMigrationHostedService : IHostedService, IDisposable
else
{
_logger.LogError(e,
"Database unavailable for migration. Trying again (attempt #{0})...", i + 1);
"Database unavailable for migration. Trying again (attempt #{AttemptNumber})...", i + 1);
await Task.Delay(20000, cancellationToken);
}
}