Skip to content

Commit

Permalink
chore(analysis): adjust memlab analyze object error message
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JacksonGL authored and facebook-github-bot committed Aug 30, 2024
1 parent 0504bd4 commit 4f6de3d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/heap-analysis/src/plugins/ObjectContentAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import BaseAnalysis from '../BaseAnalysis';
import pluginUtils from '../PluginUtils';
import OutputOption from '../options/HeapAnalysisOutputOption';

class GlobalVariableAnalysis extends BaseAnalysis {
export default class ObjectContentAnalysis extends BaseAnalysis {
getCommandName(): string {
return 'object';
}
Expand All @@ -36,12 +36,15 @@ class GlobalVariableAnalysis extends BaseAnalysis {

/** @internal */
async process(options: HeapAnalysisOptions): Promise<void> {
const snapshot = await pluginUtils.loadHeapSnapshot(options);
const nodeId = config.focusFiberNodeId;
if (nodeId < 0) {
utils.haltOrThrow('Specify an object by --node-id');
return;
}
const snapshot = await pluginUtils.loadHeapSnapshot(options);
const node = snapshot.getNodeById(nodeId);
if (!node) {
info.error(`Object @${nodeId} is not found.`);
info.lowLevel(`Specify an object by --node-id`);
utils.haltOrThrow(`Object @${nodeId} is not found.`);
return;
}

Expand Down Expand Up @@ -119,5 +122,3 @@ class GlobalVariableAnalysis extends BaseAnalysis {
return ret;
}
}

export default GlobalVariableAnalysis;

0 comments on commit 4f6de3d

Please sign in to comment.