Skip to content

Commit ea14345

Browse files
committed
Merge branch 'handle-ssl-exceptions' of https://github.com/aroben/RestSharp into aroben-handle-ssl-exceptions
Fixed Conflicts: RestSharp/Http.Async.cs
2 parents 079c821 + 9b98ba3 commit ea14345

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

RestSharp/Http.Async.cs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,17 @@ private void RequestStreamCallback(IAsyncResult result, Action<HttpResponse> cal
192192
}
193193
}
194194
}
195-
catch (WebException ex)
195+
catch (Exception ex)
196196
{
197-
if (ex.Status == WebExceptionStatus.RequestCanceled)
197+
HttpResponse response;
198+
if (ex is WebException && ((WebException)ex).Status == WebExceptionStatus.RequestCanceled)
198199
{
199-
var response = new HttpResponse {ResponseStatus = ResponseStatus.TimedOut};
200-
ExecuteCallback(response, callback);
200+
response = new HttpResponse {ResponseStatus = ResponseStatus.TimedOut};
201+
ExecuteCallback (response, callback);
201202
return;
202203
}
203-
}
204-
catch (Exception ex)
205-
{
206-
var response = new HttpResponse
204+
205+
response = new HttpResponse
207206
{
208207
ErrorMessage = ex.Message,
209208
ErrorException = ex,
@@ -300,9 +299,9 @@ private void ResponseCallback(IAsyncResult result, Action<HttpResponse> callback
300299
ExecuteCallback(response, callback);
301300
});
302301
}
303-
catch(WebException ex)
302+
catch(Exception ex)
304303
{
305-
if(ex.Status == WebExceptionStatus.RequestCanceled)
304+
if(ex is WebException && ((WebException)ex).Status == WebExceptionStatus.RequestCanceled)
306305
{
307306
response.ResponseStatus = ResponseStatus.Aborted;
308307
ExecuteCallback(response, callback);
@@ -314,13 +313,6 @@ private void ResponseCallback(IAsyncResult result, Action<HttpResponse> callback
314313
response.ResponseStatus = ResponseStatus.Error;
315314
ExecuteCallback(response, callback);
316315
}
317-
catch(Exception ex)
318-
{
319-
response.ErrorMessage = ex.Message;
320-
response.ErrorException = ex;
321-
response.ResponseStatus = ResponseStatus.Error;
322-
ExecuteCallback(response, callback);
323-
}
324316
}
325317

326318
private static void ExecuteCallback(HttpResponse response, Action<HttpResponse> callback)

0 commit comments

Comments
 (0)