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,20 +92,18 @@ 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)) {
case 0:
return `setInterval(function () { ${utils.script.safely(cmds)} }, ${random.range(100, 400)} )`
case 1:
return `setTimeout(function () { ${utils.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)} }`
}
// Wrap each command in try/catch for use in setInterval, setTimeout, repeater
switch (random.number(50)) {
case 0:
return script.safely(`setInterval(function () { ${script.safely(cmds)} }, ${random.range(100, 400)} )`)
case 1:
return script.safely(`setTimeout(function () { ${script.safely(cmds)} }, ${random.range(100, 400)} )`)
case 2:
let n = random.number(random.number(30))
return script.safely(`for (let i = 0; i < ${n}; i++) { ${script.safely(cmds)} }`)
default:
return script.safely(cmds)
}
return utils.script.safely(cmds)
}
}