diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2013-02-09 10:07:53 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2013-02-09 10:07:53 -0800 |
commit | f12f5a159afcfd28bd0b0db451bbc390ab40c515 (patch) | |
tree | a6bb597432fda6ac9907cdf2d13cd2141a33a453 /src/DotNetOpenAuth.Core/Messaging/Channel.cs | |
parent | 96b8187ba34f9da5c5dc0e3399daf4c39d967184 (diff) | |
download | DotNetOpenAuth-f12f5a159afcfd28bd0b0db451bbc390ab40c515.zip DotNetOpenAuth-f12f5a159afcfd28bd0b0db451bbc390ab40c515.tar.gz DotNetOpenAuth-f12f5a159afcfd28bd0b0db451bbc390ab40c515.tar.bz2 |
Restores exception wrapping.
Diffstat (limited to 'src/DotNetOpenAuth.Core/Messaging/Channel.cs')
-rw-r--r-- | src/DotNetOpenAuth.Core/Messaging/Channel.cs | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/Channel.cs b/src/DotNetOpenAuth.Core/Messaging/Channel.cs index 36c91c7..359257c 100644 --- a/src/DotNetOpenAuth.Core/Messaging/Channel.cs +++ b/src/DotNetOpenAuth.Core/Messaging/Channel.cs @@ -20,6 +20,7 @@ namespace DotNetOpenAuth.Messaging { using System.Net.Http; using System.Net.Http.Headers; using System.Net.Mime; + using System.Net.Sockets; using System.Runtime.Serialization.Json; using System.Text; using System.Threading; @@ -667,23 +668,27 @@ namespace DotNetOpenAuth.Messaging { IDirectResponseProtocolMessage responseMessage; using (var httpClient = this.HostFactories.CreateHttpClient()) { - using (HttpResponseMessage response = await httpClient.SendAsync(webRequest, cancellationToken)) { - response.EnsureSuccessStatusCode(); - if (response.Content == null) { - return null; + try { + using (HttpResponseMessage response = await httpClient.SendAsync(webRequest, cancellationToken)) { + response.EnsureSuccessStatusCode(); + if (response.Content == null) { + return null; + } + + responseFields = await this.ReadFromResponseCoreAsync(response); + if (responseFields == null) { + return null; + } + + responseMessage = this.MessageFactory.GetNewResponseMessage(request, responseFields); + if (responseMessage == null) { + return null; + } + + this.OnReceivingDirectResponse(response, responseMessage); } - - responseFields = await this.ReadFromResponseCoreAsync(response); - if (responseFields == null) { - return null; - } - - responseMessage = this.MessageFactory.GetNewResponseMessage(request, responseFields); - if (responseMessage == null) { - return null; - } - - this.OnReceivingDirectResponse(response, responseMessage); + } catch (HttpRequestException ex) { + throw ErrorUtilities.Wrap(ex, "Error sending HTTP request or receiving response."); } } |