@samitouri / QOS-React / commits / 2e1b3aab91

Inline internal error message

So that it is stripped out by the error code transform

Andrew Clark committed Feb 6, 2017 at 15:43 UTC 2e1b3aab912de264060437b826e65d881a9bf9b0
7 files changed +67 -86
src/renderers/shared/fiber/ReactChildFiber.js
+6 -8
@@ -72,9 +72,6 @@ const {
72 Deletion,
73 } = ReactTypeOfSideEffect;
74
75 -const internalErrorMessage =
76 - 'This error is likely caused by a bug in React. Please file an issue.';
77 -
75 function coerceRef(current: ?Fiber, element: ReactElement) {
76 let mixedRef = element.ref;
77 if (mixedRef != null && typeof mixedRef !== 'function') {
@@ -92,9 +89,10 @@ function coerceRef(current: ?Fiber, element: ReactElement) {
89 }
90 }
91 invariant(
95 - inst, 'Missing owner for string ref %s. (%s)',
96 - mixedRef,
97 - internalErrorMessage
92 + inst,
93 + 'Missing owner for string ref %s. This error is likely caused by a ' +
94 + 'bug in React. Please file an issue.',
95 + mixedRef
96 );
97 const stringRef = String(mixedRef);
98 // Check if previous string ref matches new string ref
@@ -806,8 +804,8 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
804 const iteratorFn = getIteratorFn(newChildrenIterable);
805 invariant(
806 typeof iteratorFn === 'function',
809 - 'An object is not an iterable. (%s)',
810 - internalErrorMessage
807 + 'An object is not an iterable. This error is likely caused by a bug in ' +
808 + 'React. Please file an issue.'
809 );
810
811 if (__DEV__) {
src/renderers/shared/fiber/ReactFiberBeginWork.js
+12 -15
@@ -71,9 +71,6 @@ if (__DEV__) {
71 var warnedAboutStatelessRefs = {};
72 }
73
74 -const internalErrorMessage =
75 - 'This error is likely caused by a bug in React. Please file an issue.';
76 -
74 module.exports = function<T, P, I, TI, PI, C, CX, PL>(
75 config : HostConfig<T, P, I, TI, PI, C, CX, PL>,
76 hostContext : HostContext<C, CX>,
@@ -347,8 +344,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
344 nextProps = memoizedProps;
345 invariant(
346 nextProps !== null,
350 - 'We should always have pending or current props. (%s)',
351 - internalErrorMessage
347 + 'We should always have pending or current props. This error is ' +
348 + 'likely caused by a bug in React. Please file an issue.'
349 );
350 }
351 } else if (nextProps === null || memoizedProps === nextProps) {
@@ -450,8 +447,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
447 function mountIndeterminateComponent(current, workInProgress, priorityLevel) {
448 invariant(
449 current === null,
453 - 'An indeterminate component should never have mounted. (%s)',
454 - internalErrorMessage
450 + 'An indeterminate component should never have mounted. This error is ' +
451 + 'likely caused by a bug in React. Please file an issue.'
452 );
453 var fn = workInProgress.type;
454 var props = workInProgress.pendingProps;
@@ -521,8 +518,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
518 nextCoroutine = current && current.memoizedProps;
519 invariant(
520 nextCoroutine != null,
524 - 'We should always have pending or current props. (%s)',
525 - internalErrorMessage
521 + 'We should always have pending or current props. This error is ' +
522 + 'likely caused by a bug in React. Please file an issue.'
523 );
524 }
525 } else if (nextCoroutine === null || workInProgress.memoizedProps === nextCoroutine) {
@@ -587,8 +584,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
584 nextChildren = current && current.memoizedProps;
585 invariant(
586 nextChildren != null,
590 - 'We should always have pending or current props. (%s)',
591 - internalErrorMessage
587 + 'We should always have pending or current props. This error is ' +
588 + 'likely caused by a bug in React. Please file an issue.'
589 );
590 }
591 } else if (nextChildren === null || workInProgress.memoizedProps === nextChildren) {
@@ -741,8 +738,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
738 default:
739 invariant(
740 false,
744 - 'Unknown unit of work tag. (%s)',
745 - internalErrorMessage
741 + 'Unknown unit of work tag. This error is likely caused by a bug in ' +
742 + 'React. Please file an issue.'
743 );
744 }
745 }
@@ -751,8 +748,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
748 invariant(
749 workInProgress.tag === ClassComponent ||
750 workInProgress.tag === HostRoot,
754 - 'Invalid type of work. (%s)',
755 - internalErrorMessage
751 + 'Invalid type of work. This error is likely caused by a bug in React. ' +
752 + 'Please file an issue.'
753 );
754
755 // Add an error effect so we can handle the error during the commit phase
src/renderers/shared/fiber/ReactFiberClassComponent.js
+6 -9
@@ -40,9 +40,6 @@ var invariant = require('invariant');
40
41 const isArray = Array.isArray;
42
43 -const internalErrorMessage =
44 - 'This error is likely caused by a bug in React. Please file an issue.';
45 -
43 module.exports = function(
44 scheduleUpdate : (fiber : Fiber, priorityLevel : PriorityLevel) => void,
45 getPriorityContext : () => PriorityLevel,
@@ -262,8 +259,8 @@ module.exports = function(
259 let props = workInProgress.pendingProps;
260 invariant(
261 props,
265 - 'There must be pending props for an initial mount. (%s)',
266 - internalErrorMessage
262 + 'There must be pending props for an initial mount. This error is ' +
263 + 'likely caused by a bug in React. Please file an issue.'
264 );
265
266 const unmaskedContext = getUnmaskedContext(workInProgress);
@@ -305,8 +302,8 @@ module.exports = function(
302 newProps = workInProgress.memoizedProps;
303 invariant(
304 newProps != null,
308 - 'There should always be pending or memoized props. (%s)',
309 - internalErrorMessage
305 + 'There should always be pending or memoized props. This error is ' +
306 + 'likely caused by a bug in React. Please file an issue.'
307 );
308 }
309 const newUnmaskedContext = getUnmaskedContext(workInProgress);
@@ -372,8 +369,8 @@ module.exports = function(
369 newProps = oldProps;
370 invariant(
371 newProps != null,
375 - 'There should always be pending or memoized props. (%s)',
376 - internalErrorMessage
372 + 'There should always be pending or memoized props. This error is ' +
373 + 'likely caused by a bug in React. Please file an issue.'
374 );
375 }
376 const oldContext = instance.context;
src/renderers/shared/fiber/ReactFiberCommitWork.js
+12 -15
@@ -36,9 +36,6 @@ var {
36
37 var invariant = require('invariant');
38
39 -const internalErrorMessage =
40 - 'This error is likely caused by a bug in React. Please file an issue.';
41 -
39 module.exports = function<T, P, I, TI, PI, C, CX, PL>(
40 config : HostConfig<T, P, I, TI, PI, C, CX, PL>,
41 captureError : (failedFiber : Fiber, error: Error) => ?Fiber
@@ -101,8 +98,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
98 }
99 invariant(
100 false,
104 - 'Expected to find a host parent. (%s)',
105 - internalErrorMessage
101 + 'Expected to find a host parent. This error is likely caused by a bug ' +
102 + 'in React. Please file an issue.'
103 );
104 }
105
@@ -116,8 +113,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
113 }
114 invariant(
115 false,
119 - 'Expected to find a host parent. (%s)',
120 - internalErrorMessage
116 + 'Expected to find a host parent. This error is likely caused by a bug ' +
117 + 'in React. Please file an issue.'
118 );
119 }
120
@@ -188,8 +185,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
185 default:
186 invariant(
187 false,
191 - 'Invalid host parent fiber. (%s)',
192 - internalErrorMessage
188 + 'Invalid host parent fiber. This error is likely caused by a bug ' +
189 + 'in React. Please file an issue.'
190 );
191 }
192 if (parentFiber.effectTag & ContentReset) {
@@ -393,8 +390,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
390 case HostText: {
391 invariant(
392 finishedWork.stateNode !== null && current != null,
396 - 'This should only be done during updates. (%s)',
397 - internalErrorMessage
393 + 'This should only be done during updates. This error is likely ' +
394 + 'caused by a bug in React. Please file an issue.'
395 );
396 const textInstance : TI = finishedWork.stateNode;
397 const newText : string = finishedWork.memoizedProps;
@@ -411,8 +408,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
408 default: {
409 invariant(
410 false,
414 - 'This unit of work tag should not have side-effects. (%s)',
415 - internalErrorMessage
411 + 'This unit of work tag should not have side-effects. This error is ' +
412 + 'likely caused by a bug in React. Please file an issue.'
413 );
414 }
415 }
@@ -477,8 +474,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
474 default: {
475 invariant(
476 false,
480 - 'This unit of work tag should not have side-effects. (%s)',
481 - internalErrorMessage
477 + 'This unit of work tag should not have side-effects. This error is ' +
478 + 'likely caused by a bug in React. Please file an issue.'
479 );
480 }
481 }
src/renderers/shared/fiber/ReactFiberCompleteWork.js
+11 -13
@@ -48,9 +48,6 @@ if (__DEV__) {
48
49 var invariant = require('invariant');
50
51 -const internalErrorMessage =
52 - 'This error is likely caused by a bug in React. Please file an issue.';
53 -
51 module.exports = function<T, P, I, TI, PI, C, CX, PL>(
52 config : HostConfig<T, P, I, TI, PI, C, CX, PL>,
53 hostContext : HostContext<C, CX>,
@@ -122,8 +119,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
119 var coroutine = (workInProgress.memoizedProps : ?ReactCoroutine);
120 invariant(
121 coroutine,
125 - 'Should be resolved by now. (%s)',
126 - internalErrorMessage
122 + 'Should be resolved by now. This error is likely caused by a bug in ' +
123 + 'React. Please file an issue.',
124 );
125
126 // First step of the coroutine has completed. Now we need to do the second.
@@ -241,8 +238,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
238 if (!newProps) {
239 invariant(
240 workInProgress.stateNode !== null,
244 - 'We must have new props for new mounts. (%s)',
245 - internalErrorMessage
241 + 'We must have new props for new mounts. This error is likely ' +
242 + 'caused by a bug in React. Please file an issue.'
243 );
244 // This can happen when we abort work.
245 return null;
@@ -291,8 +288,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
288 if (typeof newText !== 'string') {
289 invariant(
290 workInProgress.stateNode !== null,
294 - 'We must have new props for new mounts. (%s)',
295 - internalErrorMessage
291 + 'We must have new props for new mounts. This error is likely ' +
292 + 'caused by a bug in React. Please file an issue.'
293 );
294 // This can happen when we abort work.
295 return null;
@@ -325,15 +322,16 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
322 case IndeterminateComponent:
323 invariant(
324 false,
328 - 'An indeterminate component should have become determinate before completing. (%s)',
329 - internalErrorMessage
325 + 'An indeterminate component should have become determinate before ' +
326 + 'completing. This error is likely caused by a bug in React. Please ' +
327 + 'file an issue.'
328 );
329 // eslint-disable-next-line no-fallthrough
330 default:
331 invariant(
332 false,
335 - 'Unknown unit of work tag. (%s)',
336 - internalErrorMessage
333 + 'Unknown unit of work tag. This error is likely caused by a bug in ' +
334 + 'React. Please file an issue.'
335 );
336 }
337 }
src/renderers/shared/fiber/ReactFiberHostContext.js
+6 -9
@@ -36,9 +36,6 @@ export type HostContext<C, CX> = {
36 resetHostContainer() : void,
37 };
38
39 -const internalErrorMessage =
40 - 'This error is likely caused by a bug in React. Please file an issue.';
41 -
39 module.exports = function<T, P, I, TI, PI, C, CX, PL>(
40 config : HostConfig<T, P, I, TI, PI, C, CX, PL>
41 ) : HostContext<C, CX> {
@@ -55,8 +52,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
52 const rootInstance = rootInstanceStackCursor.current;
53 invariant(
54 rootInstance != null,
58 - 'Expected root container to exist. (%s)',
59 - internalErrorMessage
55 + 'Expected root container to exist. This error is likely caused by a ' +
56 + 'bug in React. Please file an issue.'
57 );
58 return rootInstance;
59 }
@@ -84,8 +81,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
81 const context = contextStackCursor.current;
82 invariant(
83 context != null,
87 - 'Expected host context to exist. (%s)',
88 - internalErrorMessage
84 + 'Expected host context to exist. This error is likely caused by a bug ' +
85 + 'in React. Please file an issue.'
86 );
87 return context;
88 }
@@ -94,8 +91,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
91 const rootInstance = rootInstanceStackCursor.current;
92 invariant(
93 rootInstance != null,
97 - 'Expected root host context to exist. (%s)',
98 - internalErrorMessage
94 + 'Expected root host context to exist. This error is likely caused by ' +
95 + 'a bug in React. Please file an issue.'
96 );
97
98 const context = contextStackCursor.current || emptyObject;
src/renderers/shared/fiber/ReactFiberScheduler.js
+14 -17
@@ -92,9 +92,6 @@ if (__DEV__) {
92
93 var timeHeuristicForUnitOfWork = 1;
94
95 -const internalErrorMessage =
96 - 'This error is likely caused by a bug in React. Please file an issue.';
97 -
95 module.exports = function<T, P, I, TI, PI, C, CX, PL>(config : HostConfig<T, P, I, TI, PI, C, CX, PL>) {
96 const hostContext = ReactFiberHostContext(config);
97 const { popHostContainer, popHostContext, resetHostContainer } = hostContext;
@@ -348,8 +345,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(config : HostConfig<T, P,
345 invariant(
346 root.current !== finishedWork,
347 'Cannot commit the same tree as before. This is probably a bug ' +
351 - 'related to the return field. (%s)',
352 - internalErrorMessage
348 + 'related to the return field. This error is likely caused by a bug ' +
349 + 'in React. Please file an issue.'
350 );
351
352 // Updates that occur during the commit phase should have Task priority
@@ -385,8 +382,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(config : HostConfig<T, P,
382 } catch (error) {
383 invariant(
384 nextEffect != null,
388 - 'Should have next effect. (%s)',
389 - internalErrorMessage
385 + 'Should have next effect. This error is likely caused by a bug ' +
386 + 'in React. Please file an issue.'
387 );
388 captureError(nextEffect, error);
389 // Clean-up
@@ -415,8 +412,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(config : HostConfig<T, P,
412 } catch (error) {
413 invariant(
414 nextEffect != null,
418 - 'Should have next effect. (%s)',
419 - internalErrorMessage
415 + 'Should have next effect. This error is likely caused by a bug ' +
416 + 'in React. Please file an issue.'
417 );
418 captureError(nextEffect, error);
419 if (nextEffect) {
@@ -716,8 +713,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(config : HostConfig<T, P,
713 function performWork(priorityLevel : PriorityLevel, deadline : Deadline | null) {
714 invariant(
715 !isPerformingWork,
719 - 'performWork was called recursively. (%s)',
720 - internalErrorMessage
716 + 'performWork was called recursively. This error is likely caused ' +
717 + 'by a bug in React. Please file an issue.'
718 );
719 isPerformingWork = true;
720 const isPerformingDeferredWork = Boolean(deadline);
@@ -729,8 +726,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(config : HostConfig<T, P,
726 while (priorityLevel !== NoWork && !fatalError) {
727 invariant(
728 deadline || (priorityLevel < HighPriority),
732 - 'Cannot perform deferred work without a deadline. (%s)',
733 - internalErrorMessage
729 + 'Cannot perform deferred work without a deadline. This error is ' +
730 + 'likely caused by a bug in React. Please file an issue.'
731 );
732
733 // Before starting any work, check to see if there are any pending
@@ -1001,8 +998,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(config : HostConfig<T, P,
998
999 invariant(
1000 capturedError != null,
1004 - 'No error for given unit of work. (%s)',
1005 - internalErrorMessage
1001 + 'No error for given unit of work. This error is likely caused by a ' +
1002 + 'bug in React. Please file an issue.'
1003 );
1004
1005 let error;
@@ -1038,8 +1035,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(config : HostConfig<T, P,
1035 default:
1036 invariant(
1037 false,
1041 - 'Invalid type of work. (%s)',
1042 - internalErrorMessage
1038 + 'Invalid type of work. This error is likely caused by a bug in ' +
1039 + 'React. Please file an issue.'
1040 );
1041 }
1042 }