From 7850dc6485538e952a8a73051d887478325a3104 Mon Sep 17 00:00:00 2001 From: Shumer Date: Fri, 30 Jul 2021 18:33:51 +0300 Subject: [PATCH] ROYAL-1834 Update ActionPolicy for REST requests to handle all exceptions (#33) --- src/Global/GlobalAssemblyInfo.cs | 2 +- .../Rest/v2x/Repository/ActionPolicies.cs | 23 +------------------ 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/src/Global/GlobalAssemblyInfo.cs b/src/Global/GlobalAssemblyInfo.cs index c0d597b..ec2d94f 100644 --- a/src/Global/GlobalAssemblyInfo.cs +++ b/src/Global/GlobalAssemblyInfo.cs @@ -27,4 +27,4 @@ // 2.9.0.0 - magento 2 supported, 9 build, 0 subversion (includes significant features and codechanges) -[ assembly : AssemblyVersion( "2.18.4.0" ) ] +[ assembly : AssemblyVersion( "2.18.5.0" ) ] diff --git a/src/MagentoAccess/Services/Rest/v2x/Repository/ActionPolicies.cs b/src/MagentoAccess/Services/Rest/v2x/Repository/ActionPolicies.cs index 58979c9..b4474d8 100644 --- a/src/MagentoAccess/Services/Rest/v2x/Repository/ActionPolicies.cs +++ b/src/MagentoAccess/Services/Rest/v2x/Repository/ActionPolicies.cs @@ -1,6 +1,4 @@ using System; -using System.Net; -using System.Net.Http; using System.Threading.Tasks; using MagentoAccess.Misc; using Netco.ActionPolicyServices; @@ -9,26 +7,7 @@ namespace MagentoAccess.Services.Rest.v2x.Repository { internal static class ActionPolicies { - public static ActionPolicyAsync RepeatOnChannelProblemAsync { get; } = ActionPolicyAsync.From( ( exception => - { - var magentoWebException = exception as MagentoWebException; - if ( magentoWebException != null - && magentoWebException.StatusCode != null ) - { - switch( magentoWebException.StatusCode ) - { - case HttpStatusCode.NotFound: - case HttpStatusCode.BadRequest: - case HttpStatusCode.ServiceUnavailable: - case HttpStatusCode.BadGateway: - return true; - default: - return false; - } - } - - return false; - } ) ) + public static ActionPolicyAsync RepeatOnChannelProblemAsync { get; } = ActionPolicyAsync.Handle< Exception >() .RetryAsync( 7, async ( ex, i ) => { MagentoLogger.Log().Trace( ex, "Retrying Magento API call due to channel problem for the {0} time", i );