protected void AssertFileIsNotBeingSynced(string fileName, IStorageActionsAccessor accessor, bool wrapByResponseException = false) { if (FileLockManager.TimeoutExceeded(fileName, accessor)) { FileLockManager.UnlockByDeletingSyncConfiguration(fileName, accessor); } else { Log.Debug("Cannot execute operation because file '{0}' is being synced", fileName); var beingSyncedException = new SynchronizationException(string.Format("File {0} is being synced", fileName)); if (wrapByResponseException) { throw new HttpResponseException(Request.CreateResponse((HttpStatusCode)420, beingSyncedException)); } throw beingSyncedException; } }
private static void HandleSynchronizationException(HttpActionExecutedContext ctx, SynchronizationException e) { ctx.Response = new HttpResponseMessage { StatusCode = (HttpStatusCode)420 }; SerializeError(ctx, new { Url = ctx.Request.RequestUri.PathAndQuery, Error = e.Message }); }
public void ConstructorWithErrorsTest() { const string ErrorMessage = "TestErrorMessage"; const string ExceptionMessage = "TestException"; var exception = new Exception(ExceptionMessage); var sb = new StringBuilder(ErrorMessage); sb.AppendLine().AppendLine("Errors:").Append(string.Join(Environment.NewLine, ExceptionMessage)); var instance = new SynchronizationException(ErrorMessage, new List<Exception> { exception }); Assert.AreEqual(sb.ToString(), instance.Message); }
public void ConstructorWithoutErrorsTest() { const string ErrorMessage = "TestErrorMessage"; var instance = new SynchronizationException(ErrorMessage); Assert.AreEqual(ErrorMessage, instance.Message); }
public void EmptyConstructorTest() { var instance = new SynchronizationException(); Assert.AreEqual(0, instance.Errors.Count); }