Update DevTools Error strings to support GitHub fuzzy search (#21314)
Brian Vaughn committed
Apr 19, 2021 at 13:05 UTC
4def1ceee2acc241f2434b2cfab6b8bc4c741cb3
8 files changed
+24
-24
packages/react-devtools-shared/src/devtools/ProfilerStore.js
+1
-1
@@ -113,7 +113,7 @@ export default class ProfilerStore extends EventEmitter<{|
113
}
114
115
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}"`,
117
);
118
}
119
packages/react-devtools-shared/src/devtools/store.js
+7
-7
@@ -794,7 +794,7 @@ export default class Store extends EventEmitter<{|
794
795
if (this._idToElement.has(id)) {
796
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.`,
798
);
799
}
800
@@ -857,7 +857,7 @@ export default class Store extends EventEmitter<{|
857
858
if (!this._idToElement.has(parentID)) {
859
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.`,
861
);
862
}
863
@@ -909,7 +909,7 @@ export default class Store extends EventEmitter<{|
909
910
if (!this._idToElement.has(id)) {
911
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.`,
913
);
914
}
915
@@ -918,7 +918,7 @@ export default class Store extends EventEmitter<{|
918
const element = ((this._idToElement.get(id): any): Element);
919
const {children, ownerID, parentID, weight} = element;
920
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.`);
922
}
923
924
this._idToElement.delete(id);
@@ -941,7 +941,7 @@ export default class Store extends EventEmitter<{|
941
parentElement = ((this._idToElement.get(parentID): any): Element);
942
if (parentElement === undefined) {
943
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.`,
945
);
946
}
947
const index = parentElement.children.indexOf(id);
@@ -1002,7 +1002,7 @@ export default class Store extends EventEmitter<{|
1002
1003
if (!this._idToElement.has(id)) {
1004
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.`,
1006
);
1007
}
1008
@@ -1055,7 +1055,7 @@ export default class Store extends EventEmitter<{|
1055
haveErrorsOrWarningsChanged = true;
1056
break;
1057
default:
1058
- throw Error(`Unsupported Bridge operation ${operation}`);
1058
+ throw Error(`Unsupported Bridge operation "${operation}"`);
1059
}
1060
}
1061
packages/react-devtools-shared/src/devtools/utils.js
+2
-2
@@ -114,7 +114,7 @@ export function printStore(
114
const element = store.getElementAtIndex(i);
115
116
if (element == null) {
117
- throw Error(`Could not find element at index ${i}`);
117
+ throw Error(`Could not find element at index "${i}"`);
118
}
119
120
const printedSelectedMarker = printSelectedMarker(i);
@@ -131,7 +131,7 @@ export function printStore(
131
// Make sure the pretty-printed test align with the Store's reported number of total rows.
132
if (rootWeight !== store.numElements) {
133
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}")`,
135
);
136
}
137
packages/react-devtools-shared/src/devtools/views/ErrorBoundary/githubAPI.js
+1
-1
@@ -18,7 +18,7 @@ export async function searchGitHubIssues(
18
message: string,
19
): Promise<GitHubIssue | null> {
20
// Remove Fiber IDs from error message (as those will be unique).
21
- message = message.replace(/"[0-9]+"/, '');
21
+ message = message.replace(/"[0-9]+"/g, '');
22
23
const filters = [
24
'in:title',
packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js
+4
-8
@@ -116,7 +116,7 @@ export function getCommitTree({
116
}
117
118
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}"`,
120
);
121
}
122
@@ -194,9 +194,7 @@ function updateTree(
194
195
if (nodes.has(id)) {
196
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.`,
198
);
199
}
200
@@ -269,9 +267,7 @@ function updateTree(
267
268
if (!nodes.has(id)) {
269
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.`,
271
);
272
}
273
@@ -350,7 +346,7 @@ function updateTree(
346
break;
347
348
default:
353
- throw Error(`Unsupported Bridge operation ${operation}`);
349
+ throw Error(`Unsupported Bridge operation "${operation}"`);
350
}
351
}
352
packages/react-devtools-shared/src/devtools/views/Profiler/utils.js
+6
-2
@@ -53,12 +53,16 @@ export function prepareProfilingDataFrontendFromBackendAndStore(
53
}) => {
54
const operations = operationsByRootID.get(rootID);
55
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
+ );
59
}
60
61
const snapshots = snapshotsByRootID.get(rootID);
62
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
+ );
66
}
67
68
// Do not filter empty commits from the profiler data!
packages/react-devtools-shared/src/inspectedElementMutableSource.js
+2
-2
@@ -77,7 +77,7 @@ export function inspectElement({
77
// If the Element is still in the Store, we can eagerly remove it from the Map.
78
inspectedElementMap.delete(element);
79
80
- throw Error(`Element ${id} not found`);
80
+ throw Error(`Element "${id}" not found`);
81
82
case 'full-data':
83
const fullData = ((data: any): InspectElementFullData);
@@ -127,6 +127,6 @@ export function inspectElement({
127
break;
128
}
129
130
- throw Error(`Unable to inspect element with id ${id}`);
130
+ throw Error(`Unable to inspect element with id "${id}"`);
131
});
132
}
packages/react-devtools-shared/src/utils.js
+1
-1
@@ -241,7 +241,7 @@ export function printOperationsArray(operations: Array<number>) {
241
);
242
break;
243
default:
244
- throw Error(`Unsupported Bridge operation ${operation}`);
244
+ throw Error(`Unsupported Bridge operation "${operation}"`);
245
}
246
}
247