Skip to content

Commit

Permalink
Merge pull request #1092 from y-lohse/feat/cli-error-handling
Browse files Browse the repository at this point in the history
Feat/cli error handling
  • Loading branch information
smwhr authored Nov 16, 2024
2 parents 1e3ec51 + ba1ae45 commit 927c304
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions script/inkjs-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ if(!inputFile.endsWith(".json")){
)

const c = new Compiler(mainInk, options);
const rstory = c.Compile();
let rstory:Story|null = null;
try {
rstory = c.Compile();
} catch (error: unknown) {
if((error as Error).message != "Compilation failed.") throw error; //re-throw if an illegitimate js error
}

if (!rstory) {
process.stderr.write("*** Compilation failed ***\n");
process.exit(1);
}

Expand All @@ -84,7 +89,7 @@ if(!inputFile.endsWith(".json")){
}
}else{
if(printStats){
process.stderr.write("warning: Could not generate stats for an already compiled story. Try it on a .ink file instead." + "\n");
process.stderr.write("WARNING: Could not generate stats for an already compiled story. Try it on a .ink file instead." + "\n");
printStats = false;
}

Expand Down

0 comments on commit 927c304

Please sign in to comment.