Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline internal error message #8937

Merged
merged 1 commit into from
Feb 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/renderers/shared/fiber/ReactChildFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ const {
Deletion,
} = ReactTypeOfSideEffect;

const internalErrorMessage =
'This error is likely caused by a bug in React. Please file an issue.';

function coerceRef(current: ?Fiber, element: ReactElement) {
let mixedRef = element.ref;
if (mixedRef != null && typeof mixedRef !== 'function') {
Expand All @@ -92,9 +89,10 @@ function coerceRef(current: ?Fiber, element: ReactElement) {
}
}
invariant(
inst, 'Missing owner for string ref %s. (%s)',
mixedRef,
internalErrorMessage
inst,
'Missing owner for string ref %s. This error is likely caused by a ' +
'bug in React. Please file an issue.',
mixedRef
);
const stringRef = String(mixedRef);
// Check if previous string ref matches new string ref
Expand Down Expand Up @@ -806,8 +804,8 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
const iteratorFn = getIteratorFn(newChildrenIterable);
invariant(
typeof iteratorFn === 'function',
'An object is not an iterable. (%s)',
internalErrorMessage
'An object is not an iterable. This error is likely caused by a bug in ' +
'React. Please file an issue.'
);

if (__DEV__) {
Expand Down
27 changes: 12 additions & 15 deletions src/renderers/shared/fiber/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ if (__DEV__) {
var warnedAboutStatelessRefs = {};
}

const internalErrorMessage =
'This error is likely caused by a bug in React. Please file an issue.';

module.exports = function<T, P, I, TI, PI, C, CX, PL>(
config : HostConfig<T, P, I, TI, PI, C, CX, PL>,
hostContext : HostContext<C, CX>,
Expand Down Expand Up @@ -347,8 +344,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
nextProps = memoizedProps;
invariant(
nextProps !== null,
'We should always have pending or current props. (%s)',
internalErrorMessage
'We should always have pending or current props. This error is ' +
'likely caused by a bug in React. Please file an issue.'
);
}
} else if (nextProps === null || memoizedProps === nextProps) {
Expand Down Expand Up @@ -450,8 +447,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
function mountIndeterminateComponent(current, workInProgress, priorityLevel) {
invariant(
current === null,
'An indeterminate component should never have mounted. (%s)',
internalErrorMessage
'An indeterminate component should never have mounted. This error is ' +
'likely caused by a bug in React. Please file an issue.'
);
var fn = workInProgress.type;
var props = workInProgress.pendingProps;
Expand Down Expand Up @@ -521,8 +518,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
nextCoroutine = current && current.memoizedProps;
invariant(
nextCoroutine != null,
'We should always have pending or current props. (%s)',
internalErrorMessage
'We should always have pending or current props. This error is ' +
'likely caused by a bug in React. Please file an issue.'
);
}
} else if (nextCoroutine === null || workInProgress.memoizedProps === nextCoroutine) {
Expand Down Expand Up @@ -587,8 +584,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
nextChildren = current && current.memoizedProps;
invariant(
nextChildren != null,
'We should always have pending or current props. (%s)',
internalErrorMessage
'We should always have pending or current props. This error is ' +
'likely caused by a bug in React. Please file an issue.'
);
}
} else if (nextChildren === null || workInProgress.memoizedProps === nextChildren) {
Expand Down Expand Up @@ -741,8 +738,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
default:
invariant(
false,
'Unknown unit of work tag. (%s)',
internalErrorMessage
'Unknown unit of work tag. This error is likely caused by a bug in ' +
'React. Please file an issue.'
);
}
}
Expand All @@ -751,8 +748,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
invariant(
workInProgress.tag === ClassComponent ||
workInProgress.tag === HostRoot,
'Invalid type of work. (%s)',
internalErrorMessage
'Invalid type of work. This error is likely caused by a bug in React. ' +
'Please file an issue.'
);

// Add an error effect so we can handle the error during the commit phase
Expand Down
15 changes: 6 additions & 9 deletions src/renderers/shared/fiber/ReactFiberClassComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ var invariant = require('invariant');

const isArray = Array.isArray;

const internalErrorMessage =
'This error is likely caused by a bug in React. Please file an issue.';

module.exports = function(
scheduleUpdate : (fiber : Fiber, priorityLevel : PriorityLevel) => void,
getPriorityContext : () => PriorityLevel,
Expand Down Expand Up @@ -262,8 +259,8 @@ module.exports = function(
let props = workInProgress.pendingProps;
invariant(
props,
'There must be pending props for an initial mount. (%s)',
internalErrorMessage
'There must be pending props for an initial mount. This error is ' +
'likely caused by a bug in React. Please file an issue.'
);

const unmaskedContext = getUnmaskedContext(workInProgress);
Expand Down Expand Up @@ -305,8 +302,8 @@ module.exports = function(
newProps = workInProgress.memoizedProps;
invariant(
newProps != null,
'There should always be pending or memoized props. (%s)',
internalErrorMessage
'There should always be pending or memoized props. This error is ' +
'likely caused by a bug in React. Please file an issue.'
);
}
const newUnmaskedContext = getUnmaskedContext(workInProgress);
Expand Down Expand Up @@ -372,8 +369,8 @@ module.exports = function(
newProps = oldProps;
invariant(
newProps != null,
'There should always be pending or memoized props. (%s)',
internalErrorMessage
'There should always be pending or memoized props. This error is ' +
'likely caused by a bug in React. Please file an issue.'
);
}
const oldContext = instance.context;
Expand Down
27 changes: 12 additions & 15 deletions src/renderers/shared/fiber/ReactFiberCommitWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ var {

var invariant = require('invariant');

const internalErrorMessage =
'This error is likely caused by a bug in React. Please file an issue.';

module.exports = function<T, P, I, TI, PI, C, CX, PL>(
config : HostConfig<T, P, I, TI, PI, C, CX, PL>,
captureError : (failedFiber : Fiber, error: Error) => ?Fiber
Expand Down Expand Up @@ -101,8 +98,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
}
invariant(
false,
'Expected to find a host parent. (%s)',
internalErrorMessage
'Expected to find a host parent. This error is likely caused by a bug ' +
'in React. Please file an issue.'
);
}

Expand All @@ -116,8 +113,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
}
invariant(
false,
'Expected to find a host parent. (%s)',
internalErrorMessage
'Expected to find a host parent. This error is likely caused by a bug ' +
'in React. Please file an issue.'
);
}

Expand Down Expand Up @@ -188,8 +185,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
default:
invariant(
false,
'Invalid host parent fiber. (%s)',
internalErrorMessage
'Invalid host parent fiber. This error is likely caused by a bug ' +
'in React. Please file an issue.'
);
}
if (parentFiber.effectTag & ContentReset) {
Expand Down Expand Up @@ -393,8 +390,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
case HostText: {
invariant(
finishedWork.stateNode !== null && current != null,
'This should only be done during updates. (%s)',
internalErrorMessage
'This should only be done during updates. This error is likely ' +
'caused by a bug in React. Please file an issue.'
);
const textInstance : TI = finishedWork.stateNode;
const newText : string = finishedWork.memoizedProps;
Expand All @@ -411,8 +408,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
default: {
invariant(
false,
'This unit of work tag should not have side-effects. (%s)',
internalErrorMessage
'This unit of work tag should not have side-effects. This error is ' +
'likely caused by a bug in React. Please file an issue.'
);
}
}
Expand Down Expand Up @@ -477,8 +474,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
default: {
invariant(
false,
'This unit of work tag should not have side-effects. (%s)',
internalErrorMessage
'This unit of work tag should not have side-effects. This error is ' +
'likely caused by a bug in React. Please file an issue.'
);
}
}
Expand Down
24 changes: 11 additions & 13 deletions src/renderers/shared/fiber/ReactFiberCompleteWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ if (__DEV__) {

var invariant = require('invariant');

const internalErrorMessage =
'This error is likely caused by a bug in React. Please file an issue.';

module.exports = function<T, P, I, TI, PI, C, CX, PL>(
config : HostConfig<T, P, I, TI, PI, C, CX, PL>,
hostContext : HostContext<C, CX>,
Expand Down Expand Up @@ -122,8 +119,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
var coroutine = (workInProgress.memoizedProps : ?ReactCoroutine);
invariant(
coroutine,
'Should be resolved by now. (%s)',
internalErrorMessage
'Should be resolved by now. This error is likely caused by a bug in ' +
'React. Please file an issue.',
);

// First step of the coroutine has completed. Now we need to do the second.
Expand Down Expand Up @@ -241,8 +238,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
if (!newProps) {
invariant(
workInProgress.stateNode !== null,
'We must have new props for new mounts. (%s)',
internalErrorMessage
'We must have new props for new mounts. This error is likely ' +
'caused by a bug in React. Please file an issue.'
);
// This can happen when we abort work.
return null;
Expand Down Expand Up @@ -291,8 +288,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
if (typeof newText !== 'string') {
invariant(
workInProgress.stateNode !== null,
'We must have new props for new mounts. (%s)',
internalErrorMessage
'We must have new props for new mounts. This error is likely ' +
'caused by a bug in React. Please file an issue.'
);
// This can happen when we abort work.
return null;
Expand Down Expand Up @@ -325,15 +322,16 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
case IndeterminateComponent:
invariant(
false,
'An indeterminate component should have become determinate before completing. (%s)',
internalErrorMessage
'An indeterminate component should have become determinate before ' +
'completing. This error is likely caused by a bug in React. Please ' +
'file an issue.'
);
// eslint-disable-next-line no-fallthrough
default:
invariant(
false,
'Unknown unit of work tag. (%s)',
internalErrorMessage
'Unknown unit of work tag. This error is likely caused by a bug in ' +
'React. Please file an issue.'
);
}
}
Expand Down
15 changes: 6 additions & 9 deletions src/renderers/shared/fiber/ReactFiberHostContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ export type HostContext<C, CX> = {
resetHostContainer() : void,
};

const internalErrorMessage =
'This error is likely caused by a bug in React. Please file an issue.';

module.exports = function<T, P, I, TI, PI, C, CX, PL>(
config : HostConfig<T, P, I, TI, PI, C, CX, PL>
) : HostContext<C, CX> {
Expand All @@ -55,8 +52,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
const rootInstance = rootInstanceStackCursor.current;
invariant(
rootInstance != null,
'Expected root container to exist. (%s)',
internalErrorMessage
'Expected root container to exist. This error is likely caused by a ' +
'bug in React. Please file an issue.'
);
return rootInstance;
}
Expand Down Expand Up @@ -84,8 +81,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
const context = contextStackCursor.current;
invariant(
context != null,
'Expected host context to exist. (%s)',
internalErrorMessage
'Expected host context to exist. This error is likely caused by a bug ' +
'in React. Please file an issue.'
);
return context;
}
Expand All @@ -94,8 +91,8 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
const rootInstance = rootInstanceStackCursor.current;
invariant(
rootInstance != null,
'Expected root host context to exist. (%s)',
internalErrorMessage
'Expected root host context to exist. This error is likely caused by ' +
'a bug in React. Please file an issue.'
);

const context = contextStackCursor.current || emptyObject;
Expand Down
Loading