From 4fcc25a22972ea07fbb2ddda62f8ccc89c81f175 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Fri, 21 Jul 2017 15:34:41 -0700 Subject: [PATCH] Support throwing null (#10213) * Support throwing null In JavaScript, you can throw values of any type, not just errors. That includes null. We currently rely on null checks to determine if a user- provided function has thrown. This refactors our error handling code to keep track of an explicit boolean flag instead. * Add DOM fixture test case for break on exception behavior * preventDefault error events during feature test We call invokeGuardedCallbackDev at startup as part of a feature test. But we don't want those errors to log to the console. * Add throwing null test case * Use ReactFeatureFlags instead of ReactDOMFeatureFlags React ART uses this, too. * Non-errors in error logger If a non-error is thrown, we'll coerce the value to a string and use that as the message. --- fixtures/dom/src/components/Header.js | 1 + .../fixtures/error-handling/index.js | 88 +++++++ fixtures/dom/src/components/fixtures/index.js | 3 + scripts/fiber/tests-passing.txt | 13 +- scripts/jest/fiber.setup.js | 1 + .../shared/fiber/ReactFiberCommitWork.js | 16 +- .../shared/fiber/ReactFiberErrorLogger.js | 31 ++- .../shared/fiber/ReactFiberScheduler.js | 73 +++--- src/renderers/shared/utils/ReactErrorUtils.js | 229 ++++++++++++------ .../shared/utils/ReactFeatureFlags.js | 2 + .../utils/__tests__/ReactErrorUtils-test.js | 74 +++--- 11 files changed, 390 insertions(+), 141 deletions(-) create mode 100644 fixtures/dom/src/components/fixtures/error-handling/index.js diff --git a/fixtures/dom/src/components/Header.js b/fixtures/dom/src/components/Header.js index 9a4a0a932d..bb19e6247a 100644 --- a/fixtures/dom/src/components/Header.js +++ b/fixtures/dom/src/components/Header.js @@ -59,6 +59,7 @@ class Header extends React.Component { Input change events +