Skip to content

Commit f33fa2d

Browse files
author
Michael Hallett
committed
Cleared up build error and added if/def's to the response status extensions to allow the ToWebException to be used with silverlight
1 parent ce49d8b commit f33fa2d

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

RestSharp.Silverlight/RestSharp.Silverlight.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@
170170
<Compile Include="..\RestSharp\Extensions\ResponseExtensions.cs">
171171
<Link>Extensions\ResponseExtensions.cs</Link>
172172
</Compile>
173+
<Compile Include="..\RestSharp\Extensions\ResponseStatusExtensions.cs">
174+
<Link>Extensions\ResponseStatusExtensions.cs</Link>
175+
</Compile>
173176
<Compile Include="..\RestSharp\Extensions\StringExtensions.cs">
174177
<Link>Extensions\StringExtensions.cs</Link>
175178
</Compile>

RestSharp/Extensions/ResponseStatusExtensions.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,39 @@ public static WebException ToWebException(this ResponseStatus responseStatus)
1717
{
1818
case ResponseStatus.None:
1919
return new WebException("The request could not be processed.",
20-
WebExceptionStatus.ServerProtocolViolation);
20+
#if !SILVERLIGHT
21+
WebExceptionStatus.ServerProtocolViolation
22+
#else
23+
WebExceptionStatus.UnknownError
24+
#endif
25+
);
2126

2227
case ResponseStatus.Error:
2328
return new WebException("An error occurred while processing the request.",
24-
WebExceptionStatus.ServerProtocolViolation);
29+
#if !SILVERLIGHT
30+
WebExceptionStatus.ServerProtocolViolation
31+
#else
32+
WebExceptionStatus.UnknownError
33+
#endif
34+
);
2535

2636
case ResponseStatus.TimedOut:
27-
return new WebException("The request timed-out.", WebExceptionStatus.Timeout);
37+
return new WebException("The request timed-out.",
38+
#if !SILVERLIGHT
39+
WebExceptionStatus.Timeout
40+
#else
41+
WebExceptionStatus.UnknownError
42+
#endif
43+
);
2844

2945
case ResponseStatus.Aborted:
30-
return new WebException("The request was aborted.", WebExceptionStatus.Timeout);
46+
return new WebException("The request was aborted.",
47+
#if !SILVERLIGHT
48+
WebExceptionStatus.Timeout
49+
#else
50+
WebExceptionStatus.RequestCanceled
51+
#endif
52+
);
3153

3254
default:
3355
throw new ArgumentOutOfRangeException("responseStatus");

0 commit comments

Comments
 (0)