public void TestExceptionEnumerable() { var innerException = new SocketException(); var nextException = new HttpRequestException("Socket exception", innerException); var otherNextException = new CouchbaseLiteException(); var aggregate = new AggregateException("OMG", nextException, otherNextException); CollectionAssert.AreEqual(new Exception[] { innerException, nextException, otherNextException }, new ExceptionEnumerable(aggregate).ToArray()); }
public void TestExceptionEnumerable() { var innerException = new SocketException(); var nextException = new HttpRequestException("Socket exception", innerException); var otherNextException = new CouchbaseLiteException(); var aggregate = new AggregateException("OMG", nextException, otherNextException); string statusCode; Assert.IsTrue(Misc.IsTransientNetworkError(aggregate, out statusCode)); CollectionAssert.AreEqual(new Exception[] { innerException, nextException, otherNextException }, new ExceptionEnumerable(aggregate).ToArray()); }
/// <summary> /// Uploads the revision as JSON instead of multipart. /// </summary> /// <remarks> /// Fallback to upload a revision if UploadMultipartRevision failed due to the server's rejecting /// multipart format. /// </remarks> /// <param name="rev">Rev.</param> private void UploadJsonRevision(RevisionInternal rev) { // Get the revision's properties: if (!LocalDatabase.InlineFollowingAttachmentsIn(rev)) { LastError = new CouchbaseLiteException(StatusCode.BadAttachment); RevisionFailed(); return; } var path = string.Format("/{0}?new_edits=false", Uri.EscapeUriString(rev.GetDocId())); SendAsyncRequest(HttpMethod.Put, path, rev.GetProperties(), (result, e) => { if (e != null) { LastError = e; RevisionFailed(); } else { Log.V(TAG, "Sent {0} (JSON), response={1}", rev, result); SafeIncrementCompletedChangesCount(); RemovePending (rev); } }); }
// Fallback to upload a revision if uploadMultipartRevision failed due to the server's rejecting // multipart format. private void UploadJsonRevision(RevisionInternal rev) { // Get the revision's properties: if (!db.InlineFollowingAttachmentsIn(rev)) { error = new CouchbaseLiteException(Status.BadAttachment); RevisionFailed(); return; } Log.V(Log.TagSync, "%s | %s: uploadJsonRevision() calling asyncTaskStarted()", this , Sharpen.Thread.CurrentThread()); AsyncTaskStarted(); string path = string.Format("/%s?new_edits=false", URIUtils.Encode(rev.GetDocId() )); SendAsyncRequest("PUT", path, rev.GetProperties(), new _RemoteRequestCompletionBlock_594 (this, rev)); }