-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move handling of CRM rate limit exceptions into CrmEntityChangesServi…
…ce (#875)
- Loading branch information
Showing
3 changed files
with
27 additions
and
27 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
TeachingRecordSystem/src/TeachingRecordSystem.Core/Dqt/ExceptionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.ServiceModel; | ||
using Microsoft.Xrm.Sdk; | ||
|
||
namespace TeachingRecordSystem.Core.Dqt; | ||
|
||
public static class ExceptionExtensions | ||
{ | ||
public static bool IsCrmRateLimitException(this Exception exception, out TimeSpan retryAfter) | ||
{ | ||
if (exception is FaultException<OrganizationServiceFault> fault && | ||
fault.Detail.ErrorDetails.TryGetValue("Retry-After", out var retryAfterObj) && | ||
retryAfterObj is TimeSpan retryAfterTs) | ||
{ | ||
retryAfter = retryAfterTs; | ||
return true; | ||
} | ||
|
||
retryAfter = default; | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters