Skip to content

Commit b393a6a

Browse files
committed
catch exceptions
1 parent 07c5fe3 commit b393a6a

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

packages/cli/src/commands/node.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ export default class NodeCommand extends Command {
4646
const { flags, args } = await this.parse(NodeCommand);
4747

4848
if (args.install) {
49-
await installGraphNode(flags.tag, flags['bin-dir']);
49+
try {
50+
await installGraphNode(flags.tag, flags['bin-dir']);
51+
} catch (e) {
52+
this.error(`Failed to install: ${e.message}`, { exit: 1 });
53+
}
5054
return;
5155
}
5256

@@ -61,9 +65,10 @@ async function installGraphNode(tag?: string, binDir?: string) {
6165
const tmpDir = await fs.promises.mkdtemp(path.join(tmpBase, 'graph-node-'));
6266
let progressBar: ProgressBar | undefined;
6367

64-
let downloadPath: string;
65-
try {
66-
downloadPath = await downloadGraphNodeRelease(latestRelease, tmpDir, (downloaded, total) => {
68+
const downloadPath = await downloadGraphNodeRelease(
69+
latestRelease,
70+
tmpDir,
71+
(downloaded, total) => {
6772
if (!total) return;
6873

6974
progressBar ||= new ProgressBar(`Downloading ${latestRelease} [:bar] :percent`, {
@@ -74,11 +79,8 @@ async function installGraphNode(tag?: string, binDir?: string) {
7479
});
7580

7681
progressBar.tick(downloaded - (progressBar.curr || 0));
77-
});
78-
} catch (e) {
79-
print.error(e);
80-
throw e;
81-
}
82+
},
83+
);
8284

8385
let extractedPath: string;
8486

0 commit comments

Comments
 (0)