Skip to content

Commit

Permalink
fix(compile): better error message invoke error
Browse files Browse the repository at this point in the history
If the command used to compile cannot be found, we now give a sensible
error message, and checks the exit code of the child.
  • Loading branch information
fjebaker committed Nov 12, 2024
1 parent 172be2c commit 596d5a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/commands/compile.zig
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,17 @@ fn compileNote(
const ext = note.getExtension();

const compiler = try self.getCompiler(allocator, root, ext);
return try compiler.compileNote(allocator, note, root, .{});
return compiler.compileNote(allocator, note, root, .{}) catch |err|
switch (err) {
error.FileNotFound => {
return cli.throwError(
err,
"No such command: '{s}'",
.{compiler.command[0]},
);
},
else => return err,
};
}

fn getCompiler(
Expand Down
4 changes: 3 additions & 1 deletion src/topology/TextCompiler.zig
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ fn runCommand(

const term = try proc.wait();
switch (term) {
.Exited => {},
.Exited => |code| {
if (code != 0) return Error.CompileError;
},
.Signal => return Error.CompileInterrupted,
else => return Error.CompileError,
}
Expand Down

0 comments on commit 596d5a2

Please sign in to comment.