Permalink
Browse files

Store the URL of the request that is faulted.

  • Loading branch information...
1 parent 2d86d1e commit 07726c528e93984753bea74cd610f3cd633e501d @fitzchak fitzchak committed Jan 22, 2012
@@ -17,6 +17,7 @@
using Raven.Abstractions.Data;
using Raven.Client.Connection;
using Raven.Client.Document;
+using Raven.Client.Silverlight.Extensions;
using Raven.Json.Linq;
using Raven.Client.Extensions;
@@ -97,6 +98,7 @@ private Task<string> ReadResponseStringAsync()
{
return WaitForTask.ContinueWith(_ => webRequest
.GetResponseAsync()
+ .AddUrlIfFaulting(webRequest.RequestUri)
.ContinueWith(t => ReadStringInternal(() => t.Result))
.ContinueWith(task => RetryIfNeedTo(task, ReadResponseStringAsync))
.Unwrap())
@@ -145,6 +147,7 @@ public Task<byte[]> ReadResponseBytesAsync()
{
return WaitForTask.ContinueWith(_ => webRequest
.GetResponseAsync()
+ .AddUrlIfFaulting(webRequest.RequestUri)
.ContinueWith(t => ReadResponse(() => t.Result, ConvertStreamToBytes))
.ContinueWith(task => RetryIfNeedTo(task, ReadResponseBytesAsync))
.Unwrap())
@@ -0,0 +1,22 @@
+using System;
+using System.Threading.Tasks;
+
+namespace Raven.Client.Silverlight.Extensions
+{
+ public static class TaskExtensions
+ {
+ public static Task<T> AddUrlIfFaulting<T>(this Task<T> parent, Uri uri)
+ {
+ return parent.ContinueWith(task =>
+ {
+ if (task.IsFaulted)
+ {
+ task.Exception.Data["Url"] = uri;
+ }
+
+ return task;
+ })
+ .Unwrap();
+ }
+ }
+}
@@ -315,6 +315,7 @@
<Compile Include="Connection\HttpJsonRequestHelper.cs" />
<Compile Include="Connection\RavenUrlExtensions.cs" />
<Compile Include="Data\ServerRequestError.cs" />
+ <Compile Include="Extensions\TaskExtensions.cs" />
<Compile Include="MissingFromSilverlight\Stopwatch.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

0 comments on commit 07726c5

Please sign in to comment.