mirror of
https://github.com/bitwarden/server.git
synced 2026-01-31 14:13:18 +08: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:
@@ -1,5 +1,5 @@
|
|||||||
using Bit.Core.Utilities;
|
using System.Data.Common;
|
||||||
using Microsoft.Data.SqlClient;
|
using Bit.Core.Utilities;
|
||||||
|
|
||||||
namespace Bit.Admin.HostedServices;
|
namespace Bit.Admin.HostedServices;
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ public class DatabaseMigrationHostedService : IHostedService, IDisposable
|
|||||||
// TODO: Maybe flip a flag somewhere to indicate migration is complete??
|
// TODO: Maybe flip a flag somewhere to indicate migration is complete??
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch (SqlException e)
|
catch (DbException e)
|
||||||
{
|
{
|
||||||
if (i >= maxMigrationAttempts)
|
if (i >= maxMigrationAttempts)
|
||||||
{
|
{
|
||||||
@@ -40,7 +40,7 @@ public class DatabaseMigrationHostedService : IHostedService, IDisposable
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.LogError(e,
|
_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);
|
await Task.Delay(20000, cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user