From df62063c8edce9f6294197eaa63d741c7a1eacf8 Mon Sep 17 00:00:00 2001 From: Florent Vilmart Date: Sun, 21 Jan 2018 17:43:57 -0500 Subject: [PATCH] Bolts doesnt infer failed tasks with NSError as a return type, always return failed tasks if needed --- Parse/Parse/PFObject.m | 6 +++--- Parse/Parse/PFUser.m | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Parse/Parse/PFObject.m b/Parse/Parse/PFObject.m index 4cd306d78..04efff0f2 100644 --- a/Parse/Parse/PFObject.m +++ b/Parse/Parse/PFObject.m @@ -500,7 +500,7 @@ + (BFTask *)_deepSaveAsyncChildrenOfObject:(id)object withCurrentUser:(PFUser *) [object _objectWillSave]; NSError *error; if (![object _checkSaveParametersWithCurrentUser:currentUser error:&error]) { - return error; + return [BFTask taskWithError:error]; } command = [object _constructSaveCommandForChanges:[object unsavedChanges] sessionToken:sessionToken @@ -626,7 +626,7 @@ + (BFTask *)_enqueueSaveEventuallyChildrenOfObject:(PFObject *)object currentUse // We do cycle-detection when building the list of objects passed to this // function, so this should never get called. But we should check for it // anyway, so that we get an exception instead of an infinite loop. - PFPrecondition(current.count != 0, @"Unable to save a PFObject with a relation to a cycle."); + PFPreconditionWithTask(current.count != 0, @"Unable to save a PFObject with a relation to a cycle."); // If a lazy user is one of the objects in the array, resolve its laziness now and // remove it from the list of things to save. @@ -1467,7 +1467,7 @@ - (BFTask *)saveAsync:(BFTask *)toAwait { return [[childrenTask continueWithSuccessBlock:^id(BFTask *task) { NSError *error; if (![self _checkSaveParametersWithCurrentUser:currentUser error:&error]) { - return error; + return [BFTask taskWithError:error]; } PFRESTCommand *command = [self _constructSaveCommandForChanges:changes sessionToken:sessionToken diff --git a/Parse/Parse/PFUser.m b/Parse/Parse/PFUser.m index 90eb9e874..4f472ff94 100644 --- a/Parse/Parse/PFUser.m +++ b/Parse/Parse/PFUser.m @@ -509,7 +509,7 @@ - (BFTask *)signUpAsync:(BFTask *)toAwait { // self doesn't have any outstanding saves, so we can safely merge its operations // into the current user. - PFPrecondition(!self._current, @"Attempt to merge currentUser with itself."); + PFPreconditionWithTask(!self._current, @"Attempt to merge currentUser with itself."); @synchronized ([currentUser lock]) { NSString *oldUsername = [currentUser.username copy];