Wrap all runner output in try/catch

This commit is contained in:
pyoor 2018-08-27 19:00:00 -04:00
parent a0c59d400c
commit a74b09d2c1

View file

@ -92,21 +92,19 @@ class script extends utils {
cmds = (Array.isArray(cmds)) ? cmds : [cmds]
cmds = cmds.filter((i) => i !== undefined)
if (cmds.length) {
if (random.chance(50)) {
// Wrap each command in try/catch for use in setInterval, setTimeout, repeater
switch (random.number(3)) {
switch (random.number(50)) {
case 0:
return `setInterval(function () { ${utils.script.safely(cmds)} }, ${random.range(100, 400)} )`
return script.safely(`setInterval(function () { ${script.safely(cmds)} }, ${random.range(100, 400)} )`)
case 1:
return `setTimeout(function () { ${utils.script.safely(cmds)} }, ${random.range(100, 400)} )`
return script.safely(`setTimeout(function () { ${script.safely(cmds)} }, ${random.range(100, 400)} )`)
case 2:
let n = random.number(random.number(30))
return `for (let i = 0; i < ${n}; i++) { ${utils.script.safely(cmds)} }`
return script.safely(`for (let i = 0; i < ${n}; i++) { ${script.safely(cmds)} }`)
default:
return script.safely(cmds)
}
}
return utils.script.safely(cmds)
}
}
static safely (obj) {