Browse Source

Use `catch (Exception e) when`.

pull/10713/head
maliming 5 years ago
parent
commit
a652a04fd2
No known key found for this signature in database GPG Key ID: 96224957E51C89E
  1. 98
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs

98
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs

@ -187,17 +187,12 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
) )
); );
} }
catch (Exception e) catch (Exception e) when (e is InvalidOperationException || e is NotSupportedException)
{ {
if (e is InvalidOperationException || e is NotSupportedException) Logger.LogError(TransactionsNotSupportedErrorMessage);
{ Logger.LogException(e);
Logger.LogError(TransactionsNotSupportedErrorMessage);
Logger.LogException(e); return dbContext;
}
else
{
throw;
}
} }
return dbContext; return dbContext;
@ -230,19 +225,12 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
dbContext.Database.BeginTransaction(); dbContext.Database.BeginTransaction();
} }
} }
catch (Exception e) catch (Exception e) when (e is InvalidOperationException || e is NotSupportedException)
{ {
if (e is InvalidOperationException || e is NotSupportedException) Logger.LogError(TransactionsNotSupportedErrorMessage);
{ Logger.LogException(e);
Logger.LogError(TransactionsNotSupportedErrorMessage);
Logger.LogException(e); return dbContext;
return dbContext;
}
else
{
throw;
}
} }
} }
} }
@ -255,19 +243,12 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
*/ */
dbContext.Database.BeginTransaction(); dbContext.Database.BeginTransaction();
} }
catch (Exception e) catch (Exception e) when (e is InvalidOperationException || e is NotSupportedException)
{ {
if (e is InvalidOperationException || e is NotSupportedException) Logger.LogError(TransactionsNotSupportedErrorMessage);
{ Logger.LogException(e);
Logger.LogError(TransactionsNotSupportedErrorMessage);
Logger.LogException(e); return dbContext;
return dbContext;
}
else
{
throw;
}
} }
} }
@ -301,17 +282,12 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
) )
); );
} }
catch (Exception e) catch (Exception e) when (e is InvalidOperationException || e is NotSupportedException)
{ {
if (e is InvalidOperationException || e is NotSupportedException) Logger.LogError(TransactionsNotSupportedErrorMessage);
{ Logger.LogException(e);
Logger.LogError(TransactionsNotSupportedErrorMessage);
Logger.LogException(e); return dbContext;
}
else
{
throw;
}
} }
return dbContext; return dbContext;
@ -349,19 +325,12 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
); );
} }
} }
catch (Exception e) catch (Exception e) when (e is InvalidOperationException || e is NotSupportedException)
{ {
if (e is InvalidOperationException || e is NotSupportedException) Logger.LogError(TransactionsNotSupportedErrorMessage);
{ Logger.LogException(e);
Logger.LogError(TransactionsNotSupportedErrorMessage);
Logger.LogException(e); return dbContext;
return dbContext;
}
else
{
throw;
}
} }
} }
} }
@ -374,19 +343,12 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
*/ */
await dbContext.Database.BeginTransactionAsync(GetCancellationToken()); await dbContext.Database.BeginTransactionAsync(GetCancellationToken());
} }
catch (Exception e) catch (Exception e) when (e is InvalidOperationException || e is NotSupportedException)
{ {
if (e is InvalidOperationException || e is NotSupportedException) Logger.LogError(TransactionsNotSupportedErrorMessage);
{ Logger.LogException(e);
Logger.LogError(TransactionsNotSupportedErrorMessage);
Logger.LogException(e); return dbContext;
return dbContext;
}
else
{
throw;
}
} }
} }

Loading…
Cancel
Save