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

[Android] Add explicit error message if e.getMessage is null #13407

Closed
wants to merge 1 commit into from

Conversation

reneweb
Copy link
Contributor

@reneweb reneweb commented Apr 9, 2017

Motivation (required)

In the NetworkingModule, if the http request failed, we send a didCompleteNetworkResponse event with the error message, which is used on JS side to determine if the request was erroring. Currently we get the error message from e.getMessage(), however, not all exceptions have a message and it might therefore return null and thus resulting in no error on JS side. This change checks if the message is null and if so uses a default message.

Test Plan (required)

In android send a request using XMLHttpRequest with a timeout set to a server that has a delay larger than the timeout (so we force the timeout to happen).

const request =  new XMLHttpRequest();
request.open('GET', "http://localhost:3000/", true);
request.timeout = 1000;
request.ontimeout = () => { console.log('ontimeout'); };
request.send();

See the timeout callback being called correctly.

Fixes #11666

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. GH Review: review-needed labels Apr 9, 2017
@facebook-github-bot facebook-github-bot added GH Review: accepted Import Started This pull request has been imported. This does not imply the PR has been approved. and removed GH Review: review-needed labels Apr 27, 2017
@facebook-github-bot
Copy link
Contributor

@hramos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

thotegowda pushed a commit to thotegowda/react-native that referenced this pull request May 7, 2017
Summary:
In the NetworkingModule, if the http request failed, we send a `didCompleteNetworkResponse` event with the error message, which is used on JS side to determine if the request was erroring. Currently we get the error message from `e.getMessage()`, however, not all exceptions have a message and it might therefore return null and thus resulting in no error on JS side. This change checks if the message is null and if so uses a default message.

In android send a request using XMLHttpRequest with a timeout set to a server that has a delay larger than the timeout (so we force the timeout to happen).

```
const request =  new XMLHttpRequest();
request.open('GET', "http://localhost:3000/", true);
request.timeout = 1000;
request.ontimeout = () => { console.log('ontimeout'); };
request.send();
```

See the timeout callback being called correctly.

Fixes facebook#11666
Closes facebook#13407

Differential Revision: D4963764

Pulled By: hramos

fbshipit-source-id: 61ffcef9e0594fe9bface24fdb8bde1e6eec3990
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Import Started This pull request has been imported. This does not imply the PR has been approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants