Skip to content

Commit

Permalink
Update DevTools Error strings to support GitHub fuzzy search (faceboo…
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn authored and koto committed Jun 15, 2021
1 parent 1ea86ac commit 649c948
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default class ProfilerStore extends EventEmitter<{|
}

throw Error(
`Could not find commit data for root "${rootID}" and commit ${commitIndex}`,
`Could not find commit data for root "${rootID}" and commit "${commitIndex}"`,
);
}

Expand Down
14 changes: 7 additions & 7 deletions packages/react-devtools-shared/src/devtools/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ export default class Store extends EventEmitter<{|

if (this._idToElement.has(id)) {
throw Error(
`Cannot add node ${id} because a node with that id is already in the Store.`,
`Cannot add node "${id}" because a node with that id is already in the Store.`,
);
}

Expand Down Expand Up @@ -857,7 +857,7 @@ export default class Store extends EventEmitter<{|

if (!this._idToElement.has(parentID)) {
throw Error(
`Cannot add child ${id} to parent ${parentID} because parent node was not found in the Store.`,
`Cannot add child "${id}" to parent "${parentID}" because parent node was not found in the Store.`,
);
}

Expand Down Expand Up @@ -909,7 +909,7 @@ export default class Store extends EventEmitter<{|

if (!this._idToElement.has(id)) {
throw Error(
`Cannot remove node ${id} because no matching node was found in the Store.`,
`Cannot remove node "${id}" because no matching node was found in the Store.`,
);
}

Expand All @@ -918,7 +918,7 @@ export default class Store extends EventEmitter<{|
const element = ((this._idToElement.get(id): any): Element);
const {children, ownerID, parentID, weight} = element;
if (children.length > 0) {
throw new Error(`Node ${id} was removed before its children.`);
throw new Error(`Node "${id}" was removed before its children.`);
}

this._idToElement.delete(id);
Expand All @@ -941,7 +941,7 @@ export default class Store extends EventEmitter<{|
parentElement = ((this._idToElement.get(parentID): any): Element);
if (parentElement === undefined) {
throw Error(
`Cannot remove node ${id} from parent ${parentID} because no matching node was found in the Store.`,
`Cannot remove node "${id}" from parent "${parentID}" because no matching node was found in the Store.`,
);
}
const index = parentElement.children.indexOf(id);
Expand Down Expand Up @@ -1002,7 +1002,7 @@ export default class Store extends EventEmitter<{|

if (!this._idToElement.has(id)) {
throw Error(
`Cannot reorder children for node ${id} because no matching node was found in the Store.`,
`Cannot reorder children for node "${id}" because no matching node was found in the Store.`,
);
}

Expand Down Expand Up @@ -1055,7 +1055,7 @@ export default class Store extends EventEmitter<{|
haveErrorsOrWarningsChanged = true;
break;
default:
throw Error(`Unsupported Bridge operation ${operation}`);
throw Error(`Unsupported Bridge operation "${operation}"`);
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/react-devtools-shared/src/devtools/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export function printStore(
const element = store.getElementAtIndex(i);

if (element == null) {
throw Error(`Could not find element at index ${i}`);
throw Error(`Could not find element at index "${i}"`);
}

const printedSelectedMarker = printSelectedMarker(i);
Expand All @@ -131,7 +131,7 @@ export function printStore(
// Make sure the pretty-printed test align with the Store's reported number of total rows.
if (rootWeight !== store.numElements) {
throw Error(
`Inconsistent Store state. Individual root weights (${rootWeight}) do not match total weight (${store.numElements})`,
`Inconsistent Store state. Individual root weights ("${rootWeight}") do not match total weight ("${store.numElements}")`,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function searchGitHubIssues(
message: string,
): Promise<GitHubIssue | null> {
// Remove Fiber IDs from error message (as those will be unique).
message = message.replace(/"[0-9]+"/, '');
message = message.replace(/"[0-9]+"/g, '');

const filters = [
'in:title',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function getCommitTree({
}

throw Error(
`getCommitTree(): Unable to reconstruct tree for root "${rootID}" and commit ${commitIndex}`,
`getCommitTree(): Unable to reconstruct tree for root "${rootID}" and commit "${commitIndex}"`,
);
}

Expand Down Expand Up @@ -194,9 +194,7 @@ function updateTree(

if (nodes.has(id)) {
throw new Error(
'Commit tree already contains fiber ' +
id +
'. This is a bug in React DevTools.',
`Commit tree already contains fiber "${id}". This is a bug in React DevTools.`,
);
}

Expand Down Expand Up @@ -269,9 +267,7 @@ function updateTree(

if (!nodes.has(id)) {
throw new Error(
'Commit tree does not contain fiber ' +
id +
'. This is a bug in React DevTools.',
`Commit tree does not contain fiber "${id}". This is a bug in React DevTools.`,
);
}

Expand Down Expand Up @@ -350,7 +346,7 @@ function updateTree(
break;

default:
throw Error(`Unsupported Bridge operation ${operation}`);
throw Error(`Unsupported Bridge operation "${operation}"`);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ export function prepareProfilingDataFrontendFromBackendAndStore(
}) => {
const operations = operationsByRootID.get(rootID);
if (operations == null) {
throw Error(`Could not find profiling operations for root ${rootID}`);
throw Error(
`Could not find profiling operations for root "${rootID}"`,
);
}

const snapshots = snapshotsByRootID.get(rootID);
if (snapshots == null) {
throw Error(`Could not find profiling snapshots for root ${rootID}`);
throw Error(
`Could not find profiling snapshots for root "${rootID}"`,
);
}

// Do not filter empty commits from the profiler data!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function inspectElement({
// If the Element is still in the Store, we can eagerly remove it from the Map.
inspectedElementMap.delete(element);

throw Error(`Element ${id} not found`);
throw Error(`Element "${id}" not found`);

case 'full-data':
const fullData = ((data: any): InspectElementFullData);
Expand Down Expand Up @@ -127,6 +127,6 @@ export function inspectElement({
break;
}

throw Error(`Unable to inspect element with id ${id}`);
throw Error(`Unable to inspect element with id "${id}"`);
});
}
2 changes: 1 addition & 1 deletion packages/react-devtools-shared/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export function printOperationsArray(operations: Array<number>) {
);
break;
default:
throw Error(`Unsupported Bridge operation ${operation}`);
throw Error(`Unsupported Bridge operation "${operation}"`);
}
}

Expand Down

0 comments on commit 649c948

Please sign in to comment.