-
-
Notifications
You must be signed in to change notification settings - Fork 878
Consistency errors #1237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consistency errors #1237
Conversation
827c95b
to
963b2d0
Compare
@montymxb as of now, it looks like all the PFConsistencyAsset calls are 'safe' and reporting proper errors to the users when 'developing'. Errors that would occur in flight (when wrapped into an async task have been replaced by error pointers). |
Additionally @marcgovi, could you have a quick look? |
cca3587
to
c59c775
Compare
@montymxb as it stands now, I made a pre release 1.17.0-alpha.1 in order to be able to test it out in the wild, I also updated liveQuery as this project relies on the decoders which have changed their interface in order to support encoding failures. I tested on a project and it all look great. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nits then LGTM
NSDictionary *encodedDimensions = [[PFNoObjectEncoder objectEncoder] encodeObject:dimensions]; | ||
NSError *error; | ||
NSDictionary *encodedDimensions = [[PFNoObjectEncoder objectEncoder] encodeObject:dimensions error:&error]; | ||
if (encodedDimensions == nil && error != nil) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in objective c we don't have to check for nill != nil
, but maybe it is more elegant this way ...
@@ -105,12 +108,13 @@ + (instancetype)commandFromDictionaryRepresentation:(NSDictionary *)dictionary { | |||
PFRESTCommand *command = [self commandWithHTTPPath:dictionary[PFRESTCommandHTTPPathEncodingKey] | |||
httpMethod:dictionary[PFRESTCommandHTTPMethodEncodingKey] | |||
parameters:dictionary[PFRESTCommandParametersEncodingKey] | |||
sessionToken:dictionary[PFRESTCommandSessionTokenEncodingKey]]; | |||
sessionToken:dictionary[PFRESTCommandSessionTokenEncodingKey] | |||
error:nil]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have to add the error handling here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should be good if I understand the codepaths correctly
self.parameters = [[PFPointerOrLocalIdObjectEncoder objectEncoder] encodeObject:data]; | ||
BOOL modified = NO; | ||
BOOL success = [[self class] forEachLocalIdIn:data doBlock:block modified:&modified error:error]; | ||
if (!success) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of something like this ?
if ([[self class] forEachLocalIdIn:data doBlock:block modified:&modified error:error]) {
self.parameters = [[PFPointerOrLocalIdObjectEncoder objectEncoder] encodeObject:data error:error];
if (self.parameters && !(error && *error)) {
return YES;
}
}
return NO;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense.
@@ -131,6 +143,8 @@ + (NSDictionary *)findCommandParametersWithOrder:(NSString *)order | |||
parameters[key] = obj; | |||
}]; | |||
|
|||
__block BOOL encodingHasErrored = NO; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can use encodingHasError
or encodingFailed
?
if (![object isKindOfClass:[NSDictionary class]]) { | ||
return object; | ||
} | ||
|
||
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithCapacity:[object count]]; | ||
__block BOOL hadFailed = NO; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can use fasFailed
or didFail
? Up to you...
NSMutableArray *encodedObjects = [objectEncoder encodeObject:self.objects]; | ||
- (id)encodeWithObjectEncoder:(PFEncoder *)objectEncoder error:(NSError **)error { | ||
NSMutableArray *encodedObjects = [objectEncoder encodeObject:self.objects error: error]; | ||
if (!encodedObjects && error && *error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we usePFPreconditionBailOnError
?
NSMutableArray *encodedObjects = [objectEncoder encodeObject:self.objects]; | ||
- (id)encodeWithObjectEncoder:(PFEncoder *)objectEncoder error:(NSError **)error { | ||
NSMutableArray *encodedObjects = [objectEncoder encodeObject:self.objects error:error]; | ||
if (!encodedObjects && error && *error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we usePFPreconditionBailOnError
?
NSMutableArray *encodedObjects = [objectEncoder encodeObject:self.objects]; | ||
- (id)encodeWithObjectEncoder:(PFEncoder *)objectEncoder error:(NSError **)error { | ||
NSMutableArray *encodedObjects = [objectEncoder encodeObject:self.objects error:error]; | ||
if (!encodedObjects && error && *error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we usePFPreconditionBailOnError
?
Parse/Parse/Internal/PFAssert.h
Outdated
@@ -66,6 +114,7 @@ do {\ | |||
format:description, ##__VA_ARGS__]; \ | |||
} while(0) | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty line added... should we remove it?
Parse/Parse/PFEncoder.m
Outdated
} | ||
return newArray; | ||
|
||
} else if ([object isKindOfClass:[NSDictionary class]]) { | ||
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:[object count]]; | ||
__block BOOL hasErrored = NO; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasErrors
?
thanks @mt81 i'll update with the nits! |
6828a72
to
25a5338
Compare
- Make Tried to get invalid local id a soft error - Make Tried to save an object with a new, unsaved child. a soft error - Make Tried to save an object with a pointer to a new, unsaved object. a soft error - Make Attempted to find non-existent uuid a soft error
- As per discussion over there, @nlutsenko and @richardjrossiii were A1 on the resolution Thanks @czgarrett for the fix Closes #931
… return failed tasks if needed
d028cc4
to
278ab82
Compare
* 1. Fix typo PFPreconditionFailOnError and PFPreconditionFailAndSetError. 2. If there is a new object in OfflineStore, should not send the exception when the saved object update its OfflineStore cache * Change the condition about newly saved object * fix typo * Revert to PFPreconditionBailOnError and PFPreconditionBailAndSetError
This PR addresses those crashes that started happening since bumping to Bolts 1.9.0.
Starting Bolts 1.9.0, the NSExceptions are not caught by Bolts anymore, and need to be handled differently.
The best way to handle errors is to go the old style objective-c error pointer passing strategy.
This impact a large portion of the codebase as we need to forward errors from the coder / decoder.
On the public side, this should not change anything, as all failable calls will be caught by an errored BFTask.