Revision 5ce54458 trunk/Pithos.Network/RestClient.cs

b/trunk/Pithos.Network/RestClient.cs
98 98
                return response;
99 99
            }
100 100
            catch (WebException exc)
101
            {
102
                if (exc.Response!=null && exc.Response.ContentLength > 0)
101
            {                
102
                if (exc.Response!=null)
103 103
                {
104
                    string content = GetContent(exc.Response);
105
                    Trace.TraceError(content);
104
                    var response = (exc.Response as HttpWebResponse);
105
                    if (response.StatusCode == HttpStatusCode.NotModified)
106
                        return response;
107
                    if (exc.Response.ContentLength > 0)
108
                    {
109
                        string content = GetContent(exc.Response);
110
                        Trace.TraceError(content);
111
                    }
106 112
                }
107 113
                throw;
108 114
            }
......
198 204
                return 0;
199 205
            }, actualRetries);
200 206

  
201
            task.Wait();
207
            try
208
            {
209
                task.Wait();
210
            }
211
            catch (AggregateException ex)
212
            {
213
                var exc = ex.InnerException;
214
                if (exc is RetryException)
215
                {
216
                    Trace.TraceError("[{0}] RETRY FAILED for {1} after {2} retries",method,address,retries);
217
                }
218
                else
219
                {
220
                    Trace.TraceError("[{0}] FAILED for {1} with \n{2}", method, address, exc);
221
                }
222
                throw;
223

  
224
            }
225
            catch(Exception ex)
226
            {
227
                Trace.TraceError("[{0}] FAILED for {1} with \n{2}", method, address, ex);
228
                throw;
229
            }
202 230
        }
203 231
        
204 232
        /*private string RetryWithContent(string address, int retries, string method)
......
366 394
                            {
367 395
                                TimedOut = true;
368 396
                                if (retryCount == 0)
369
                                {
370
                                    Trace.TraceError("[ERROR] Timed out too many times. {0}\n", e);
397
                                {                                    
398
                                    Trace.TraceError("[ERROR] Timed out too many times. \n{0}\n",e);
371 399
                                    tcs.SetException(new RetryException("Timed out too many times.", e));                                    
372 400
                                }
373 401
                                else

Also available in: Unified diff