Wrap all runner output in try/catch
This commit is contained in:
parent
a0c59d400c
commit
a74b09d2c1
1 changed files with 11 additions and 13 deletions
|
@ -92,21 +92,19 @@ class script extends utils {
|
||||||
cmds = (Array.isArray(cmds)) ? cmds : [cmds]
|
cmds = (Array.isArray(cmds)) ? cmds : [cmds]
|
||||||
cmds = cmds.filter((i) => i !== undefined)
|
cmds = cmds.filter((i) => i !== undefined)
|
||||||
if (cmds.length) {
|
if (cmds.length) {
|
||||||
if (random.chance(50)) {
|
|
||||||
// Wrap each command in try/catch for use in setInterval, setTimeout, repeater
|
// Wrap each command in try/catch for use in setInterval, setTimeout, repeater
|
||||||
switch (random.number(3)) {
|
switch (random.number(50)) {
|
||||||
case 0:
|
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:
|
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:
|
case 2:
|
||||||
let n = random.number(random.number(30))
|
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) {
|
static safely (obj) {
|
||||||
|
|
Loading…
Reference in a new issue