refactor(errors): extract top-level error handling into shared utility

This commit is contained in:
mitchell 2026-06-17 00:48:15 -04:00
parent 56352d87ec
commit f8e0f9a368
3 changed files with 26 additions and 16 deletions

9
tts.ts
View file

@ -11,6 +11,7 @@ import chalk from "chalk";
import { execa } from "execa";
import { Window } from "happy-dom";
import wrapAnsi from "wrap-ansi";
import { handleTopLevel } from "./src/errors";
async function main() {
const start = Date.now();
@ -179,10 +180,4 @@ async function main() {
})`mpv --pause output.wav`;
}
main().catch((err) => {
if ("message" in err) {
const [columns] = process.stderr.getWindowSize();
console.error(wrapAnsi(chalk.red(err.message), columns));
} else console.log(err);
process.exit(1);
});
main().catch(handleTopLevel);