From 06d79aeb825d3bd5eecd454188fa75993076aba4 Mon Sep 17 00:00:00 2001 From: glacambre Date: Sat, 26 May 2018 21:14:30 +0200 Subject: [PATCH] excmds.ts: Add error handling to composite() --- src/excmds.ts | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/excmds.ts b/src/excmds.ts index d70c3831..b4c17df1 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -1658,21 +1658,25 @@ export function repeat(n = 1, ...exstr: string[]) { */ //#background export async function composite(...cmds: string[]) { - return cmds - .join(" ") - .split(";") - .reduce( - async (_, cmd) => { - return cmd.split("|").reduce( - async (pipedValue, cmd) => { - let [fn, args] = excmd_parser.parser(cmd) - return fn.call({}, ...args, await pipedValue) - }, - "" as any, - ) - }, - null as any, - ) + try { + return cmds + .join(" ") + .split(";") + .reduce( + async (_, cmd) => { + return cmd.split("|").reduce( + async (pipedValue, cmd) => { + let [fn, args] = excmd_parser.parser(cmd) + return fn.call({}, ...args, await pipedValue) + }, + "" as any, + ) + }, + null as any, + ) + } catch (e) { + logger.error(e) + } } //#background