Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Using pattern matching
  • Loading branch information
ealsur committed Aug 23, 2022
commit d6c98c1f617e3c37e9889b741ee0d76acdafb461
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,20 @@ public override async Task AddOrUpdateLeaseAsync(DocumentServiceLease lease)
catch (Exception ex)
{
await this.RemoveLeaseAsync(lease: lease, wasAcquired: false).ConfigureAwait(false);
if (ex is LeaseLostException leaseLostException)
switch (ex)
{
// LeaseLostException by itself is not loggable, unless it contains a related inner exception
// For cases when the lease or container has been deleted or the lease has been stolen
if (leaseLostException.InnerException != null)
{
await this.monitor.NotifyErrorAsync(lease.CurrentLeaseToken, leaseLostException.InnerException);
}
}
else
{
await this.monitor.NotifyErrorAsync(lease.CurrentLeaseToken, ex);
case LeaseLostException leaseLostException:
// LeaseLostException by itself is not loggable, unless it contains a related inner exception
// For cases when the lease or container has been deleted or the lease has been stolen
if (leaseLostException.InnerException != null)
{
await this.monitor.NotifyErrorAsync(lease.CurrentLeaseToken, leaseLostException.InnerException);
}
break;

default:
await this.monitor.NotifyErrorAsync(lease.CurrentLeaseToken, ex);
break;
}

throw;
Expand Down