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.
The text was updated successfully, but these errors were encountered:
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).
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.