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

monkey patch react native default error handling without overwriting it #492

Merged
merged 2 commits into from
Feb 4, 2016

Conversation

qbig
Copy link
Contributor

@qbig qbig commented Jan 27, 2016

'setGlobalHandler' would overwrite the default error handler for React Native. This code keeps the default handler by wrapping it the new handler. More about the global error handler for React Native could be found from this discussion: facebook/react-native#1194

@qbig
Copy link
Contributor Author

qbig commented Jan 27, 2016

@benvinegar glad to hear your thought 👍

var defaultHandler = (ErrorUtils.getGlobalHandler && ErrorUtils.getGlobalHandler())
|| ErrorUtils._globalHandler;
ErrorUtils.setGlobalHandler(function(...args){
defaultHandler(...args);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd preserve the value of this in case that's a factor later: defaultHandler.apply(this, arguments)

@benvinegar
Copy link
Contributor

One last thing – could you re-write this the avoid using the spread operator (or any ES6+ code).

I recognize that this runs fine w/ React Native, but I want to introduce some unit tests for this plugin, and requiring advanced JavaScript features complicates the test build.

@qbig
Copy link
Contributor Author

qbig commented Jan 29, 2016

@benvinegar updated accordingly 👍

benvinegar added a commit that referenced this pull request Feb 4, 2016
monkey patch react native default error handling without overwriting it
@benvinegar benvinegar merged commit b98f32f into getsentry:master Feb 4, 2016
This pull request was closed.
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