mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
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.
This commit is contained in:
@@ -2328,21 +2328,22 @@ src/renderers/shared/stack/reconciler/__tests__/Transaction-test.js
|
||||
* should allow nesting of transactions
|
||||
|
||||
src/renderers/shared/utils/__tests__/ReactErrorUtils-test.js
|
||||
* it should rethrow errors caught by invokeGuardedCallbackAndCatchFirstError (development)
|
||||
* it should rethrow caught errors (development)
|
||||
* should call the callback the passed arguments (development)
|
||||
* should call the callback with the provided context (development)
|
||||
* should return a caught error (development)
|
||||
* should return null if no error is thrown (development)
|
||||
* should catch errors (development)
|
||||
* should return false from clearCaughtError if no error was thrown (development)
|
||||
* can nest with same debug name (development)
|
||||
* does not return nested errors (development)
|
||||
* can be shimmed (development)
|
||||
* it should rethrow errors caught by invokeGuardedCallbackAndCatchFirstError (production)
|
||||
* it should rethrow caught errors (production)
|
||||
* should call the callback the passed arguments (production)
|
||||
* should call the callback with the provided context (production)
|
||||
* should return a caught error (production)
|
||||
* should return null if no error is thrown (production)
|
||||
* should catch errors (production)
|
||||
* should return false from clearCaughtError if no error was thrown (production)
|
||||
* can nest with same debug name (production)
|
||||
* does not return nested errors (production)
|
||||
* catches null values
|
||||
* can be shimmed (production)
|
||||
|
||||
src/renderers/shared/utils/__tests__/accumulateInto-test.js
|
||||
|
||||
@@ -12,6 +12,7 @@ jest.mock('ReactFeatureFlags', () => {
|
||||
const flags = require.requireActual('ReactFeatureFlags');
|
||||
return Object.assign({}, flags, {
|
||||
disableNewFiberFeatures: true,
|
||||
forceInvokeGuardedCallbackDev: true,
|
||||
});
|
||||
});
|
||||
jest.mock('ReactNativeFeatureFlags', () => {
|
||||
|
||||
Reference in New Issue
Block a user