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

Allow Promise to display error strings and not just error objects. #9989

Closed
wants to merge 8 commits into from

Conversation

mikelambert
Copy link
Contributor

No description provided.

@ghost
Copy link

ghost commented Sep 19, 2016

By analyzing the blame information on this pull request, we identified @davidaurelio and @danieldunderfelt to be potential reviewers.

@ghost ghost added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Sep 19, 2016
@@ -18,6 +18,9 @@ if (__DEV__) {
allRejections: true,
onUnhandled: (id, error = {}) => {
const {message = null, stack = null} = error;
if (typeof error === 'string' || error instanceof String) {
message = error;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message const cannot be reassigned const message

@ide
Copy link
Contributor

ide commented Sep 20, 2016

Better to handle Errors specially and then have a fallback for all non-Error types ex: with https://github.com/thejameskyle/pretty-format

@ghost
Copy link

ghost commented Sep 20, 2016

@mikelambert updated the pull request - view changes

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 20, 2016
@mikelambert
Copy link
Contributor Author

You want me to add another dependency to react-native? I can do that if desired, just figured a simple change that handled the (what I assumed, only) case of strings was a better and easier to get merged.

@ide
Copy link
Contributor

ide commented Sep 20, 2016

It's easier to get merged but more arbitrary and handling all values seems better to me.

let {message = null, stack = null} = error;
if (typeof error === 'string' || error instanceof String) {
message = error;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about `if (message == null) { message = String(error); }

let {message = null, stack = null} = error;
if (typeof error === 'string' || error instanceof String) {
message = error;
}
const warning =
`Possible Unhandled Promise Rejection (id: ${id}):\n` +
(message == null ? '' : `${message}\n`) +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or here: ${message == null ? String(error) : message}\n

@davidaurelio
Copy link
Contributor

pretty-format would work, too, of course

@mikelambert
Copy link
Contributor Author

Thanks David, I'm partial to String(error) until we find errors raised that warrant more, but let me know if you prefer pretty-format, and I'll make the change.

And sorry if I'm mistaken @ide , but I'm assuming you're an external dev chiming in but not a core RN committer, so am deferring to @davidaurelio on the pretty-format dependency. Otherwise I'm not sure how to weight your preference on this change. :)

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 20, 2016
@davidaurelio
Copy link
Contributor

@mikelambert sounds good. @ide is as core as it gets 😉

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 20, 2016
@ghost
Copy link

ghost commented Sep 23, 2016

@mikelambert updated the pull request - view changes

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 23, 2016
@ghost
Copy link

ghost commented Sep 23, 2016

@mikelambert updated the pull request - view changes

@mikelambert
Copy link
Contributor Author

Sorry for the fb-bot spam, I'm dealing with this git learning curve on my end, and screwed up my branches. This should be back to the original pull again (sorry, haven't had made time yet to make the pretty-format change and test it yet)

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 23, 2016
@ghost
Copy link

ghost commented Sep 23, 2016

@mikelambert updated the pull request - view changes

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 23, 2016
@facebook-github-bot
Copy link
Contributor

It's been a while since the last commit was reviewed and the labels show this pull request needs review. Based on the blame information for the files in this pull request we identified @danieldunderfelt as a potential reviewer. Could you take a look please or cc someone with more context?

@mikelambert
Copy link
Contributor Author

Sorry @hramos. I've just updated with the latest set of changes @ide suggested. I've tested that it works and logs correctly with:
throw 'str';
throw new Error('str');
throw new RangeError('str');

@ide
Copy link
Contributor

ide commented Nov 8, 2016

@mikelambert thanks, this is robust and simple! The CircleCI tests look like they are failing because of a JDK issue, unrelated to this PR. I don't think there are automated tests for promise rejections so we aren't missing much signal from CircleCI plus you said you manually tested it.

@hramos Could you help import this PR? It adds a dependency (https://github.com/thejameskyle/pretty-format).

@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.

@mikelambert
Copy link
Contributor Author

What is the next step for this change? @hramos imported it 18 days ago, but it is not yet in master. Is it sitting internally waiting in phabricator for review?

@mikelambert
Copy link
Contributor Author

Ping?

@mikelambert
Copy link
Contributor Author

Ping @ide @hramos ?

@ide
Copy link
Contributor

ide commented Jan 23, 2017

@ericvicenti can you import and commit this?

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Jan 23, 2017
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot facebook-github-bot added Import Failed and removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Jan 24, 2017
@facebook-github-bot
Copy link
Contributor

I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification.

@mikelambert
Copy link
Contributor Author

I've updated and fixed a merge conflict on package.json, so hopefully this should be safe to try again, Mr. @facebook-github-bot .

Sorry about the commit-log mess. My git-foo is not good enough to rebase it properly without messing up the entire branch. Will your phabricator import collapse it all? If not...I can make an attempt at rebasing and collapsing it, and worst-case submit a new clean pull request.

Thanks!

@mikelambert
Copy link
Contributor Author

Ping @ericvicenti since I re-merged master, and suspect it needs re-triggering on your end.

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Jan 26, 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.

@facebook-github-bot
Copy link
Contributor

I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification.

@facebook-github-bot facebook-github-bot removed the Import Started This pull request has been imported. This does not imply the PR has been approved. label Jan 26, 2017
@mikelambert
Copy link
Contributor Author

@hramos and @ericvicenti to clarify if this is something I need to act on or not...

  • It passes all checks according to github
  • I just recently merged to github master, dunno if I already need to do it again?
  • I'm assuming it instead must be breaking some internal test?

@hramos
Copy link
Contributor

hramos commented Jan 27, 2017

@mikelambert nothing needed on your part. Anything that touches package.json requires a manual import on our side. We have already done that part, but the internal diff is failing some internal tests. It looks like the failures are transient and unrelated. I'll kick it off again and see if it passes tests again.

Update: Actually one of the test failures is related to this diff, it looks like we need to update some things on our side to account for the additional packages.

@hramos
Copy link
Contributor

hramos commented Mar 10, 2017

Finally!

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants