Skip to content

Commit 4def1ce

Browse files
author
Brian Vaughn
authored
Update DevTools Error strings to support GitHub fuzzy search (#21314)
1 parent af1a4cb commit 4def1ce

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

packages/react-devtools-shared/src/devtools/ProfilerStore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export default class ProfilerStore extends EventEmitter<{|
113113
}
114114

115115
throw Error(
116-
`Could not find commit data for root "${rootID}" and commit ${commitIndex}`,
116+
`Could not find commit data for root "${rootID}" and commit "${commitIndex}"`,
117117
);
118118
}
119119

packages/react-devtools-shared/src/devtools/store.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ export default class Store extends EventEmitter<{|
794794

795795
if (this._idToElement.has(id)) {
796796
throw Error(
797-
`Cannot add node ${id} because a node with that id is already in the Store.`,
797+
`Cannot add node "${id}" because a node with that id is already in the Store.`,
798798
);
799799
}
800800

@@ -857,7 +857,7 @@ export default class Store extends EventEmitter<{|
857857

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

@@ -909,7 +909,7 @@ export default class Store extends EventEmitter<{|
909909

910910
if (!this._idToElement.has(id)) {
911911
throw Error(
912-
`Cannot remove node ${id} because no matching node was found in the Store.`,
912+
`Cannot remove node "${id}" because no matching node was found in the Store.`,
913913
);
914914
}
915915

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

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

10031003
if (!this._idToElement.has(id)) {
10041004
throw Error(
1005-
`Cannot reorder children for node ${id} because no matching node was found in the Store.`,
1005+
`Cannot reorder children for node "${id}" because no matching node was found in the Store.`,
10061006
);
10071007
}
10081008

@@ -1055,7 +1055,7 @@ export default class Store extends EventEmitter<{|
10551055
haveErrorsOrWarningsChanged = true;
10561056
break;
10571057
default:
1058-
throw Error(`Unsupported Bridge operation ${operation}`);
1058+
throw Error(`Unsupported Bridge operation "${operation}"`);
10591059
}
10601060
}
10611061

packages/react-devtools-shared/src/devtools/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export function printStore(
114114
const element = store.getElementAtIndex(i);
115115

116116
if (element == null) {
117-
throw Error(`Could not find element at index ${i}`);
117+
throw Error(`Could not find element at index "${i}"`);
118118
}
119119

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

packages/react-devtools-shared/src/devtools/views/ErrorBoundary/githubAPI.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export async function searchGitHubIssues(
1818
message: string,
1919
): Promise<GitHubIssue | null> {
2020
// Remove Fiber IDs from error message (as those will be unique).
21-
message = message.replace(/"[0-9]+"/, '');
21+
message = message.replace(/"[0-9]+"/g, '');
2222

2323
const filters = [
2424
'in:title',

packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export function getCommitTree({
116116
}
117117

118118
throw Error(
119-
`getCommitTree(): Unable to reconstruct tree for root "${rootID}" and commit ${commitIndex}`,
119+
`getCommitTree(): Unable to reconstruct tree for root "${rootID}" and commit "${commitIndex}"`,
120120
);
121121
}
122122

@@ -194,9 +194,7 @@ function updateTree(
194194

195195
if (nodes.has(id)) {
196196
throw new Error(
197-
'Commit tree already contains fiber ' +
198-
id +
199-
'. This is a bug in React DevTools.',
197+
`Commit tree already contains fiber "${id}". This is a bug in React DevTools.`,
200198
);
201199
}
202200

@@ -269,9 +267,7 @@ function updateTree(
269267

270268
if (!nodes.has(id)) {
271269
throw new Error(
272-
'Commit tree does not contain fiber ' +
273-
id +
274-
'. This is a bug in React DevTools.',
270+
`Commit tree does not contain fiber "${id}". This is a bug in React DevTools.`,
275271
);
276272
}
277273

@@ -350,7 +346,7 @@ function updateTree(
350346
break;
351347

352348
default:
353-
throw Error(`Unsupported Bridge operation ${operation}`);
349+
throw Error(`Unsupported Bridge operation "${operation}"`);
354350
}
355351
}
356352

packages/react-devtools-shared/src/devtools/views/Profiler/utils.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,16 @@ export function prepareProfilingDataFrontendFromBackendAndStore(
5353
}) => {
5454
const operations = operationsByRootID.get(rootID);
5555
if (operations == null) {
56-
throw Error(`Could not find profiling operations for root ${rootID}`);
56+
throw Error(
57+
`Could not find profiling operations for root "${rootID}"`,
58+
);
5759
}
5860

5961
const snapshots = snapshotsByRootID.get(rootID);
6062
if (snapshots == null) {
61-
throw Error(`Could not find profiling snapshots for root ${rootID}`);
63+
throw Error(
64+
`Could not find profiling snapshots for root "${rootID}"`,
65+
);
6266
}
6367

6468
// Do not filter empty commits from the profiler data!

packages/react-devtools-shared/src/inspectedElementMutableSource.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function inspectElement({
7777
// If the Element is still in the Store, we can eagerly remove it from the Map.
7878
inspectedElementMap.delete(element);
7979

80-
throw Error(`Element ${id} not found`);
80+
throw Error(`Element "${id}" not found`);
8181

8282
case 'full-data':
8383
const fullData = ((data: any): InspectElementFullData);
@@ -127,6 +127,6 @@ export function inspectElement({
127127
break;
128128
}
129129

130-
throw Error(`Unable to inspect element with id ${id}`);
130+
throw Error(`Unable to inspect element with id "${id}"`);
131131
});
132132
}

packages/react-devtools-shared/src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export function printOperationsArray(operations: Array<number>) {
241241
);
242242
break;
243243
default:
244-
throw Error(`Unsupported Bridge operation ${operation}`);
244+
throw Error(`Unsupported Bridge operation "${operation}"`);
245245
}
246246
}
247247

0 commit comments

Comments
 (0)