in Amazon.QLDB.Driver/session/QldbSession.cs [61:113]
internal T Execute<T>(Func<TransactionExecutor, T> func)
{
ValidationUtils.AssertNotNull(func, "func");
Transaction transaction = null;
string transactionId = QldbTransactionException.DefaultTransactionId;
try
{
transaction = this.StartTransaction();
transactionId = transaction.Id;
T returnedValue = func(new TransactionExecutor(transaction, this.serializer));
if (returnedValue is IResult result)
{
returnedValue = (T)(object)BufferedResult.BufferResult(result);
}
transaction.Commit();
return returnedValue;
}
catch (TransactionAbortedException)
{
throw;
}
catch (InvalidSessionException ise)
{
if (IsTransactionExpiredException(ise))
{
throw new QldbTransactionException(transactionId, this.TryAbort(transaction), ise);
}
else
{
throw new RetriableException(transactionId, false, ise);
}
}
catch (OccConflictException occ)
{
throw new RetriableException(transactionId, true, occ);
}
catch (AmazonServiceException ase)
{
if (ase.StatusCode == HttpStatusCode.InternalServerError ||
ase.StatusCode == HttpStatusCode.ServiceUnavailable)
{
throw new RetriableException(transactionId, this.TryAbort(transaction), ase);
}
throw new QldbTransactionException(transactionId, this.TryAbort(transaction), ase);
}
catch (Exception e)
{
throw new QldbTransactionException(transactionId, this.TryAbort(transaction), e);
}
}