JavaScripting on main() 0 ▲ Jake Worth 2 hours ago · Tech · hide · 0 comments I had ChatGPT write a JavaScript for me, and was surprised to see this arrangement: function main() { // Do work... } try { main(); } catch (error) { console.error(error); process.exitCode = 1; } I would not have written this file this way; instead, I’d have put a try/catch in the file directly and probably forgotten the exit code. This lets my script return nonzero on any error and be chained with other scripts. And it encapsulates the work in main(), a C-like flourish I admire. No comments yet. Log in to reply on the Fediverse. Comments will appear here.