mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
3a825c0360
Summary: @public `reportException` is a new method on `NativeExceptionsManager` that is designed to allow more structured and flexible JS error reporting. `reportFatalException` and `reportSoftException` are now deprecated. In addition to all the usual exception fields, `reportException` also accepts an `extraData` property which the JS exception handler can populate with arbitrary JSON-serialisable data (here: the raw stack trace, the current JS engine, and the number of frames popped off the call stack by the exception handler). The contents of `extraData` get attached as JSON to the `JavascriptException` instance (or just logged, in the case of `console.error`). This change is backwards compatible in two senses: 1. We have a JS fallback that uses `reportFatalException` and `reportSoftException` if the new native method is unavailable. 2. We have a Java fallback that implements `reportFatalException` and `reportSoftException` in terms of `reportException`. Naturally, both fallbacks mentioned above discard `extraData`. NOTE: The current implementation is Android-only; for the time being, iOS will continue to use the JS fallback. While we're in `ExceptionsManager.js`, this also changes `dismissRedbox()` to be optional (which it is, since it's Android-only); existing call sites already guard it with a null check so this requires no other changes. Reviewed By: mmmulani Differential Revision: D16133080 fbshipit-source-id: d0b209d58da40b736df63155bbea232e94ce635c