-
-
Notifications
You must be signed in to change notification settings - Fork 878
Use errors instead of exceptions when creating a PFFile. #345
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
Conversation
if (![fileManager fileExistsAtPath:path isDirectory:&directory] || directory) { | ||
NSString *message = [NSString stringWithFormat:@"Failed to create PFFile at path '%@': " | ||
"file does not exist.", path]; | ||
*error = [NSError errorWithDomain:PFParseErrorDomain |
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.
2 things here:
- let's use
PFErrorUtilities
to create an error, since it enforces PFParseErrorDomain, as well as logs to console by default. - We should fine a code that fits this best from existing error codes, or avoid using
PFParseErrorDomain
, since we have a guarantee that we never use anything other than errors defined in PFConstants (PFErrorCode
) enum.
Looks great, minus usage of errors. |
192564f
to
0492b05
Compare
@"PFFile cannot be larger than %llu bytes", PFFileMaxFileSize); | ||
if (!data) { | ||
NSString *message = @"Cannot create a PFFile with nil data."; | ||
*error = [NSError errorWithDomain:NSPOSIXErrorDomain |
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.
Let's use NSCocoaErrorDomain
with maybe NSFileNoSuchFileError
?
Be aware - Travis failed miserably on this one. |
0492b05
to
05e4990
Compare
Switching to errors provides a more consistent interface, as we should never use exceptions in objective-c except for unrecoverable errors. Fixes #338.
Ship it! |
Use errors instead of exceptions when creating a PFFile.
Switching to errors provides a more consistent interface, as we should never use exceptions in objective-c except for unrecoverable errors.
Fixes #338.