Browse Source

storage-node: cli handler expections thrown in command

Mokhtar Naamani 4 years ago
parent
commit
7cd60f73d0
1 changed files with 6 additions and 1 deletions
  1. 6 1
      storage-node/packages/cli/src/cli.ts

+ 6 - 1
storage-node/packages/cli/src/cli.ts

@@ -121,7 +121,12 @@ export async function main() {
   if (Object.prototype.hasOwnProperty.call(commands, command)) {
     // Command recognized
     const args = _.clone(cli.input).slice(1)
-    await commands[command](api, ...args)
+    try {
+      await commands[command](api, ...args)
+    } catch (err) {
+      console.error(`Command Failed: ${err}`)
+      process.exit(-1)
+    }
   } else {
     showUsageAndExit(`Command "${command}" not recognized.`)
   }