global._STRAWBERRY_CURRENT_APP = "#SYSTEM#"; process.removeAllListeners("uncaughtException"); process.on('uncaughtException', (error) => { Strawberry.Tick.Events = []; Strawberry.ProcessKeyboard = false; let lines = [ "Sorry, a system error occurred.", "\"" + global._STRAWBERRY_CURRENT_APP + "\"", " error type " + parseInt(require('crypto').createHash('md5').update(error.name).digest('hex').substring(0, 2), 16) ]; let longest = lines.reduce(function(a, b) { return a.length > b.length ? a : b }, ''); let col = "red"; let confirm = "Restart"; longest = longest + 5; let v = Math.round((process.stdout.rows / 2 + 1) - 5 - (lines.length / 2)); let horizontal = Math.round(process.stdout.columns / 2 - (1 + ((longest.length + 11) / 2))); process.stdout.cursorTo(horizontal, v); process.stdout.write(color.bgWhite[col]("┏━━━━━━" + "━".repeat(longest.length) + "━━━┓")); process.stdout.cursorTo(horizontal, v + 1); process.stdout.write(color.bgWhite[col]("┃ " + " ".repeat(longest.length) + " ┃")); let index = 1; for (let line of lines) { process.stdout.cursorTo(horizontal, v + 1 + index); if (index === 1) { process.stdout.write(color.bgWhite.black(color[col]("┃") + " " + chalk.bgRed.black("") + " " + line + " ".repeat(longest.length - line.length) + " " + color[col]("┃"))); } else { process.stdout.write(color.bgWhite.black(color[col]("┃") + " " + line + " ".repeat(longest.length - line.length) + " " + color[col]("┃"))); } index++; } process.stdout.cursorTo(horizontal, v + 1 + index); process.stdout.write(color.bgWhite[col]("┃ " + " ".repeat(longest.length) + " ┃")); process.stdout.cursorTo(horizontal, v + 2 + index); process.stdout.write(color.bgWhite[col]("┃ " + " ".repeat(longest.length - (confirm.length + 2)) + chalk.bgBlack.white(" " + confirm + " ") + " ┃")); process.stdout.cursorTo(horizontal, v + 3 + index); process.stdout.write(color.bgWhite[col]("┃ " + " ".repeat(longest.length) + " ┃")); process.stdout.cursorTo(horizontal, v + 4 + index); process.stdout.write(color.bgWhite[col]("┗━━━━━━" + "━".repeat(longest.length) + "━━━┛")); process.stdin.on('keypress', (str, key) => { if (key.sequence === "\r") { console.clear(); process.stdout.cursorTo(0, 0); setTimeout(() => { require('child_process').spawnSync(process.argv[0], process.argv.filter((_, i) => { return i > 0 }), { stdio: "inherit" }); }, 1000) } }); })