Skip to content

Catching errors from an RCTRootView #1086

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

Closed
ide opened this issue May 1, 2015 · 3 comments
Closed

Catching errors from an RCTRootView #1086

ide opened this issue May 1, 2015 · 3 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@ide
Copy link
Contributor

ide commented May 1, 2015

I want to be able to conceptually catch all errors thrown from an RCTRootView instance rather than displaying the red box. This opens the door for custom error handling and the red box could be implemented as the fallback error handler.

@nicklockwood
Copy link
Contributor

You can add a custom error handler by using RCTSetLogFunction(). This won't disable the RedBox (perhaps it should - TBD), however you can do that separately by setting RCT_DEBUG=0.

If you can think of a better solution that won't break existing expectations, I'd be happy to consider it.

In future, RCTRedBox is likely to become a module, so you'll be able to replace it by passing in an alternative module with the same name vis the moduleProvider block. For now, the only option that doesn't involve changing the RCT_DEBUG preprocessor flag would be to swizzle some methods in the RCTRedBox (we do this in some of our unit tests).

@ide
Copy link
Contributor Author

ide commented May 5, 2015

Thanks for the tip about RCTSetLogFunction(). I want to build a sort of custom console for the RCTRootView so this sounds great to start.

@ide
Copy link
Contributor Author

ide commented May 27, 2015

Handling soft/hard exceptions with the exceptions manager works well for most cases. I think there are some errors that don't go through that code path but will open up separate issues and/or PRs for those when needed.

@ide ide closed this as completed May 27, 2015
@facebook facebook locked as resolved and limited conversation to collaborators May 29, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants