@samitouri / QOSami-HFS / commits / f1f84822

CLI: nicer error formatting

Massimo Melina committed Jun 7, 2024 at 12:05 UTC f1f848220ca92c9123ddd0a5af8e724b6a11781c
1 file changed +3 -4
src/commands.ts
+3 -4
@@ -36,10 +36,9 @@ function parseCommandLine(line: string) {
36 return console.error("insufficient parameters, expected: " + cmd.params)
37 Promise.resolve(cmd.cb(...params)).then(() => console.log("+++ command executed"),
38 (err: any) => {
39 - if (typeof err === 'string')
40 - console.error("command failed:", err)
41 - else
39 + if (typeof err !== 'string' && !err?.message)
40 throw err
41 + console.error("command failed:", err.message || err)
42 })
43 }
44
@@ -98,7 +97,7 @@ const commands = {
97 },
98 update: {
99 params: '[<version>=latest]',
101 - cb: update
100 + cb: update,
101 },
102 'check-update': {
103 params: '',