-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UnexpectedHttpStatusCodeException: more verbose message (#333)
* UnexpectedHttpStatusCodeException: more verbose message * Fix * FromHttpResponseMessageAsync * Fix --------- Co-authored-by: Ilya Nikulshin <[email protected]>
- Loading branch information
1 parent
109778f
commit 5c4d635
Showing
4 changed files
with
61 additions
and
26 deletions.
There are no files selected for viewing
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
5 changes: 3 additions & 2 deletions
5
Source/EasyNetQ.Management.Client/Internals/HttpResponseMessageExtensions.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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
using System.Net; | ||
using System.Threading; | ||
|
||
namespace EasyNetQ.Management.Client.Internals; | ||
|
||
internal static class HttpResponseMessageExtensions | ||
{ | ||
public static void EnsureExpectedStatusCode(this HttpResponseMessage response, Func<HttpStatusCode, bool> isExpected) | ||
public static async Task EnsureExpectedStatusCodeAsync(this HttpResponseMessage response, Func<HttpStatusCode, bool> isExpected, CancellationToken cancellationToken = default) | ||
{ | ||
if (!isExpected(response.StatusCode)) | ||
throw new UnexpectedHttpStatusCodeException(response); | ||
throw await UnexpectedHttpStatusCodeException.FromHttpResponseMessageAsync(response, cancellationToken).ConfigureAwait(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