Skip to content

Commit 94eb9a6

Browse files
committed
Merge pull request #376 from ParsePlatform/nlutsenko.json.stream
Don't try to decode JSON object from stream if there is no such file.
2 parents 3b71db1 + c05250a commit 94eb9a6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Parse/Internal/PFJSONSerialization.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ + (id)JSONObjectFromFileAtPath:(NSString *)filePath {
5151

5252
[stream open];
5353

54+
NSError *streamError = stream.streamError;
55+
// Check if stream failed to open, because there is no such file.
56+
if (streamError && [streamError.domain isEqualToString:NSPOSIXErrorDomain] && streamError.code == ENOENT) {
57+
[stream close]; // Still close the stream.
58+
return nil;
59+
}
60+
5461
NSError *error = nil;
5562
id object = [NSJSONSerialization JSONObjectWithStream:stream options:0 error:&error];
5663
if (!object || error) {

0 commit comments

Comments
 (0)