Skip to content

Commit 83fe4d6

Browse files
committed
Stop wrapping OperationCancellationException with DbUpdateException
Fixes #15074
1 parent 8ee0305 commit 83fe4d6

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/EFCore.Relational/Update/AffectedCountModificationCommandBatch.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected override void Consume(RelationalDataReader reader)
8484
"Expected " + expectedResultSetCount + " result sets, got " + actualResultSetCount);
8585
#endif
8686
}
87-
catch (Exception ex) when (!(ex is DbUpdateException))
87+
catch (Exception ex) when (ex is not DbUpdateException and not OperationCanceledException)
8888
{
8989
throw new DbUpdateException(
9090
RelationalStrings.UpdateStoreException,
@@ -150,7 +150,7 @@ protected override async Task ConsumeAsync(
150150
"Expected " + expectedResultSetCount + " result sets, got " + actualResultSetCount);
151151
#endif
152152
}
153-
catch (Exception ex) when (!(ex is DbUpdateException))
153+
catch (Exception ex) when (ex is not DbUpdateException and not OperationCanceledException)
154154
{
155155
throw new DbUpdateException(
156156
RelationalStrings.UpdateStoreException,

src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs

+2-10
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,7 @@ public override void Execute(IRelationalConnection connection)
252252
Dependencies.Logger, CommandSource.SaveChanges));
253253
Consume(dataReader);
254254
}
255-
catch (DbUpdateException)
256-
{
257-
throw;
258-
}
259-
catch (Exception ex)
255+
catch (Exception ex) when (ex is not DbUpdateException and not OperationCanceledException)
260256
{
261257
throw new DbUpdateException(
262258
RelationalStrings.UpdateStoreException,
@@ -293,11 +289,7 @@ public override async Task ExecuteAsync(
293289
cancellationToken).ConfigureAwait(false);
294290
await ConsumeAsync(dataReader, cancellationToken).ConfigureAwait(false);
295291
}
296-
catch (DbUpdateException)
297-
{
298-
throw;
299-
}
300-
catch (Exception ex)
292+
catch (Exception ex) when (ex is not DbUpdateException and not OperationCanceledException)
301293
{
302294
throw new DbUpdateException(
303295
RelationalStrings.UpdateStoreException,

0 commit comments

Comments
 (0)