Improved error reporting
This commit is contained in:
parent
d4eb0c8a4f
commit
91813b4165
5 changed files with 48 additions and 17 deletions
|
@ -9,6 +9,7 @@ import chalk from "chalk";
|
|||
import { parseBindingFile } from "./binding";
|
||||
import { loadResourceFile } from "./resource";
|
||||
import { usage } from "./usage";
|
||||
import { ResourceFileError } from "./errors";
|
||||
|
||||
enum ExitCode {
|
||||
Success = 0,
|
||||
|
@ -201,12 +202,10 @@ try {
|
|||
const exitCode = await main();
|
||||
process.exit(exitCode);
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
console.error("Uncaught error:");
|
||||
console.error(chalk.red(error.message));
|
||||
console.error(error.stack);
|
||||
if (error instanceof ResourceFileError) {
|
||||
console.error(chalk.red(error.fmt()));
|
||||
} else {
|
||||
console.error("An unknown error occurred");
|
||||
console.error("An unexpected error occurred");
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue