From 13886d42c7f4fa475859f8e72e015e5b7948de32 Mon Sep 17 00:00:00 2001 From: Archomeda Date: Sat, 11 Mar 2023 19:36:40 +0100 Subject: [PATCH 1/2] Rework RequestException temporarily as a less breaking change compared to 2.0 --- .../WebApi/Exceptions/RequestException.cs | 57 ++++++++++++------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/Gw2Sharp/WebApi/Exceptions/RequestException.cs b/Gw2Sharp/WebApi/Exceptions/RequestException.cs index a8b42c6ef..fcfc0558f 100644 --- a/Gw2Sharp/WebApi/Exceptions/RequestException.cs +++ b/Gw2Sharp/WebApi/Exceptions/RequestException.cs @@ -6,16 +6,17 @@ namespace Gw2Sharp.WebApi.Exceptions /// /// A generic request exception used for the web API. /// - public class RequestException : RequestException + public class RequestException : Exception { /// /// Creates a new . /// /// The original request. /// The message. - /// or is . + /// or is null. public RequestException(IWebApiRequest request, string message) : - base(request, message) { } + this(request, null, message, null) + { } /// /// Creates a new . @@ -23,9 +24,10 @@ public RequestException(IWebApiRequest request, string message) : /// The original request. /// The response. /// The message. - /// or is . + /// or is null. public RequestException(IWebApiRequest request, IWebApiResponse? response, string message) : - base(request, response, message) { } + this(request, response, message, null) + { } /// /// Creates a new . @@ -33,9 +35,10 @@ public RequestException(IWebApiRequest request, IWebApiResponse? respons /// The original request. /// The message. /// The inner exception. - /// or is . + /// or is null. public RequestException(IWebApiRequest request, string message, Exception? innerException) : - base(request, message, innerException) { } + this(request, null, message, innerException) + { } /// /// Creates a new . @@ -44,9 +47,22 @@ public RequestException(IWebApiRequest request, string message, Exception? inner /// The response. /// The message. /// The inner exception. - /// or is . - public RequestException(IWebApiRequest request, IWebApiResponse? response, string message, Exception innerException) : - base(request, response, message, innerException) { } + public RequestException(IWebApiRequest request, IWebApiResponse? response, string message, Exception? innerException) : + base(message, innerException) + { + this.Request = request ?? throw new ArgumentNullException(nameof(request)); + this.Response = response; + } + + /// + /// Gets the original request. + /// + public IWebApiRequest Request { get; } + + /// + /// Gets the response. + /// + public IWebApiResponse? Response { get; } } @@ -54,7 +70,7 @@ public RequestException(IWebApiRequest request, IWebApiResponse? respons /// A generic request exception used for the web API. /// /// The response object. - public class RequestException : Exception + public class RequestException : RequestException { /// /// Creates a new . @@ -63,7 +79,8 @@ public class RequestException : Exception /// The message. /// or is . public RequestException(IWebApiRequest request, string message) : - this(request, null, message, null) { } + this(request, null, message, null) + { } /// /// Creates a new . @@ -73,7 +90,8 @@ public RequestException(IWebApiRequest request, string message) : /// The message. /// or is . public RequestException(IWebApiRequest request, IWebApiResponse? response, string message) : - this(request, response, message, null) { } + this(request, response, message, null) + { } /// /// Creates a new . @@ -83,7 +101,8 @@ public RequestException(IWebApiRequest request, IWebApiResponse? resp /// The inner exception. /// or is . public RequestException(IWebApiRequest request, string message, Exception? innerException) : - this(request, null, message, innerException) { } + this(request, null, message, innerException) + { } /// /// Creates a new . @@ -93,20 +112,14 @@ public RequestException(IWebApiRequest request, string message, Exception? inner /// The message. /// The inner exception. public RequestException(IWebApiRequest request, IWebApiResponse? response, string message, Exception? innerException) : - base(message, innerException) + base(request, null, message, innerException) { - this.Request = request ?? throw new ArgumentNullException(nameof(request)); this.Response = response; } - /// - /// Gets the original request. - /// - public IWebApiRequest Request { get; } - /// /// Gets the response. /// - public IWebApiResponse? Response { get; } + public new IWebApiResponse? Response { get; } } } From 30d3f2dbd11e497ae75809505bbacd2ef8bb4aeb Mon Sep 17 00:00:00 2001 From: Archomeda Date: Sat, 11 Mar 2023 19:42:47 +0100 Subject: [PATCH 2/2] Use see langword --- Gw2Sharp/WebApi/Exceptions/RequestException.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gw2Sharp/WebApi/Exceptions/RequestException.cs b/Gw2Sharp/WebApi/Exceptions/RequestException.cs index fcfc0558f..7e994ffc5 100644 --- a/Gw2Sharp/WebApi/Exceptions/RequestException.cs +++ b/Gw2Sharp/WebApi/Exceptions/RequestException.cs @@ -13,7 +13,7 @@ public class RequestException : Exception /// /// The original request. /// The message. - /// or is null. + /// or is . public RequestException(IWebApiRequest request, string message) : this(request, null, message, null) { } @@ -24,7 +24,7 @@ public RequestException(IWebApiRequest request, string message) : /// The original request. /// The response. /// The message. - /// or is null. + /// or is . public RequestException(IWebApiRequest request, IWebApiResponse? response, string message) : this(request, response, message, null) { } @@ -35,7 +35,7 @@ public RequestException(IWebApiRequest request, IWebApiResponse? respons /// The original request. /// The message. /// The inner exception. - /// or is null. + /// or is . public RequestException(IWebApiRequest request, string message, Exception? innerException) : this(request, null, message, innerException) { }