Skip to content
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

SDK crashed in case of network error #47

Closed
endrelovas opened this issue Dec 2, 2015 · 1 comment
Closed

SDK crashed in case of network error #47

endrelovas opened this issue Dec 2, 2015 · 1 comment

Comments

@endrelovas
Copy link

All kind of endpoint queries have one basic bug within BAAClient.m
getPath, postPath, putPath, deletePath tries to convert empty (nil) response to NSDictionary which causes the SDK to crash immediately.

This part:

    [[self.session dataTaskWithRequest:request
                     completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {

                         NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response;
                         NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:data
                                                                                    options:kNilOptions
                                                                                      error:nil];

It should investigate the error return with the completionHandler prior to convert JSON to NSDictionary.
Something like this (not a full code, never tested)

    [[self.session dataTaskWithRequest:request
                     completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                         if (error) {
                             failure(error);
                             return;
                         }

                         NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response;
                         NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:data
                                                                                    options:kNilOptions
                                                                                      error:nil];
@xinufje
Copy link

xinufje commented Dec 8, 2015

Pull request #45 fixes this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants