0

I am using the Telerik OpenAccess ORM. There are instances where an exception occurs when there are concurrent updates happening on the same database record. I am trying to catch an exception error that is being thrown:

try
{
    this._dbContext.SaveChanges();
}
catch (Telerik.OpenAccess.Exceptions.OptimisticVerificationException ex)
{
    Debug.WriteLine($"EXCEPTION ERROR CAUGHT: {ex}");
}

When I debug, I can see that the exception is being logged in the Visual Studio output window:

Telerik.OpenAccess Error: 5 : Row not found: GenericOID@fd1c5f2e ORDERS ORDER_ID=12345678
UPDATE "ORDERS" SET "DEPOSIT_AMOUNT" = ? WHERE "ORDER_ID" = ? AND "DEPOSIT_AMOUNT" = ?
(set event logging to all to see parameter values)
Exception thrown: 'Telerik.OpenAccess.Exceptions.OptimisticVerificationException' in Telerik.OpenAccess.dll

But the code doesn't fall into the catch block. Any ideas why?

PixelPaul
  • 2,609
  • 4
  • 39
  • 70
  • 4
    because it's not thrown in the try-block? Because it's already caught and handled internally? – JHBonarius Jan 04 '22 at 15:59
  • 1
    Look at the documentation for the method. If Telerik has done their job, they will document exactly what you can expect to be returned/thrown from the operation. If the OptimisticVerificationException is not rethrown after being logged, you won't be able to catch it. – David L Jan 04 '22 at 16:30
  • 2
    @JHBonarius is correct, that exception is already being caught in a `ORMManager` base class – PixelPaul Jan 04 '22 at 16:47

0 Answers0