Skip to content

Commit 4f6de3d

Browse files
JacksonGLfacebook-github-bot
authored andcommitted
chore(analysis): adjust memlab analyze object error message
Summary: Better error message for the `memlab analyze object` command in case no `--node-id` flag is provided Reviewed By: twobassdrum Differential Revision: D61983870 fbshipit-source-id: d4ac206f726505db31b6dae0dc160455a714bcf7
1 parent 0504bd4 commit 4f6de3d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/heap-analysis/src/plugins/ObjectContentAnalysis.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import BaseAnalysis from '../BaseAnalysis';
1919
import pluginUtils from '../PluginUtils';
2020
import OutputOption from '../options/HeapAnalysisOutputOption';
2121

22-
class GlobalVariableAnalysis extends BaseAnalysis {
22+
export default class ObjectContentAnalysis extends BaseAnalysis {
2323
getCommandName(): string {
2424
return 'object';
2525
}
@@ -36,12 +36,15 @@ class GlobalVariableAnalysis extends BaseAnalysis {
3636

3737
/** @internal */
3838
async process(options: HeapAnalysisOptions): Promise<void> {
39-
const snapshot = await pluginUtils.loadHeapSnapshot(options);
4039
const nodeId = config.focusFiberNodeId;
40+
if (nodeId < 0) {
41+
utils.haltOrThrow('Specify an object by --node-id');
42+
return;
43+
}
44+
const snapshot = await pluginUtils.loadHeapSnapshot(options);
4145
const node = snapshot.getNodeById(nodeId);
4246
if (!node) {
43-
info.error(`Object @${nodeId} is not found.`);
44-
info.lowLevel(`Specify an object by --node-id`);
47+
utils.haltOrThrow(`Object @${nodeId} is not found.`);
4548
return;
4649
}
4750

@@ -119,5 +122,3 @@ class GlobalVariableAnalysis extends BaseAnalysis {
119122
return ret;
120123
}
121124
}
122-
123-
export default GlobalVariableAnalysis;

0 commit comments

Comments
 (0)