From 7bacbca4e9a781442cffca691b4e0e8274bb0f0e Mon Sep 17 00:00:00 2001 From: Joshua Harms Date: Wed, 17 Apr 2024 17:16:12 -0500 Subject: [PATCH 1/2] Make ShopifyHttpException.RequestInfo a nullable string --- ShopifySharp/Infrastructure/ShopifyHttpException.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ShopifySharp/Infrastructure/ShopifyHttpException.cs b/ShopifySharp/Infrastructure/ShopifyHttpException.cs index 4006e033c..b6b99f2f3 100644 --- a/ShopifySharp/Infrastructure/ShopifyHttpException.cs +++ b/ShopifySharp/Infrastructure/ShopifyHttpException.cs @@ -5,7 +5,6 @@ namespace ShopifySharp.Infrastructure; public class ShopifyHttpException( - string requestInfo, HttpStatusCode statusCode, ICollection errors, string message, @@ -25,5 +24,6 @@ public class ShopifyHttpException( /// The X-Request-Id header returned by Shopify. This can be used when working with the Shopify support team to identify the failed request. public new readonly string? RequestId = requestId; - public readonly string RequestInfo = requestInfo; + /// Extra details about the request, for logging purposes. + public readonly string? RequestInfo = requestInfo; } From af0434cc7141a6960400788240536a00fc61729c Mon Sep 17 00:00:00 2001 From: Joshua Harms Date: Wed, 17 Apr 2024 17:16:50 -0500 Subject: [PATCH 2/2] Add ShopifyHttpException constructor with nullable RequestInfo --- .../Infrastructure/ResponseClassifierTests.cs | 2 +- .../Infrastructure/ShopifyHttpException.cs | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ShopifySharp.Tests/Infrastructure/ResponseClassifierTests.cs b/ShopifySharp.Tests/Infrastructure/ResponseClassifierTests.cs index 3ea18d885..857622fdc 100644 --- a/ShopifySharp.Tests/Infrastructure/ResponseClassifierTests.cs +++ b/ShopifySharp.Tests/Infrastructure/ResponseClassifierTests.cs @@ -142,7 +142,7 @@ private ShopifyRateLimitException CreateRateLimitException(ShopifyRateLimitReaso private ShopifyHttpException CreateHttpException(int statusCode) { - return new ShopifyHttpException(string.Empty, (HttpStatusCode)statusCode, + return new ShopifyHttpException((HttpStatusCode)statusCode, [], "some-exception-message", "some-raw-response-body", diff --git a/ShopifySharp/Infrastructure/ShopifyHttpException.cs b/ShopifySharp/Infrastructure/ShopifyHttpException.cs index b6b99f2f3..69ef0c177 100644 --- a/ShopifySharp/Infrastructure/ShopifyHttpException.cs +++ b/ShopifySharp/Infrastructure/ShopifyHttpException.cs @@ -9,8 +9,8 @@ public class ShopifyHttpException( ICollection errors, string message, string rawResponseBody, - string? requestId -) : ShopifyException(statusCode, errors, message, rawResponseBody, requestId) + string? requestId) + : ShopifyException(statusCode, errors, message, rawResponseBody, requestId) { /// The Http response status code. public new readonly HttpStatusCode HttpStatusCode = statusCode; @@ -25,5 +25,17 @@ public class ShopifyHttpException( public new readonly string? RequestId = requestId; /// Extra details about the request, for logging purposes. - public readonly string? RequestInfo = requestInfo; + public readonly string? RequestInfo; + + public ShopifyHttpException( + string requestInfo, + HttpStatusCode statusCode, + ICollection errors, + string message, + string rawResponseBody, + string? requestId) + : this(statusCode, errors, message, rawResponseBody, requestId) + { + RequestInfo = requestInfo; + } }