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

Changing Error to Warning #1860

Closed
wants to merge 1 commit into from
Closed

Changing Error to Warning #1860

wants to merge 1 commit into from

Conversation

PhilippKrone
Copy link
Contributor

As discussed with @nicklockwood in the issue #1780, the error should be changed to a warning to not break fetch() to send a POST to a remote API without wanting to parse the reply. E.g. google sends back an empty 1x1px gif when POSTing something to google analytics.

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks!

@PhilippKrone
Copy link
Contributor Author

@nicklockwood how do I have to catch the exception then? At the moment, the app is returning:

Unrecognized request token: <__NSCFLocalDataTask: 0x7fc898d85640>{ taskIdentifier: 1 } { completed }'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000110140c65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010fdd5bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x0000000110140aca +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x000000010d22fa57 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 169
    4   Yoloci                              0x000000010b11b97c __49-[RCTNetworking URLRequest:didCompleteWithError:]_block_invoke + 332
    5   libdispatch.dylib                   0x0000000112110186 _dispatch_call_block_and_release + 12
    6   libdispatch.dylib                   0x000000011212f614 _dispatch_client_callout + 8

Shouldnt the following be fine as well, or do you really want to throw an error?

  if (!responseText && data.length) {
    [request.handler cancelRequest:requestToken];
    RCTLogWarn(@"Received data was invalid.");
    return;
  }

Or do I miss a way to handle the thrown exception?

@nicklockwood
Copy link
Contributor

The code sample I posted doesn't throw an exception, it just returns the error to the handler. I'm not sure why you're getting an exception thrown.

@nicklockwood
Copy link
Contributor

I think I'll have to dig into this further. It may not be possible to cancel and return an error with the current architecture.

@sahrens sahrens closed this in 4b5b952 Jul 9, 2015
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

Successfully merging this pull request may close these issues.

3 participants