Skip to content

Commit 16887e9

Browse files
committed
accept a writer for error reporting
1 parent 28dcf0e commit 16887e9

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/Ast.zig

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,10 +1029,15 @@ pub fn printInterfaceAsHtml(
10291029
}
10301030
}
10311031

1032-
pub fn printErrors(ast: Ast, src: []const u8, path: ?[]const u8) void {
1032+
pub fn printErrors(
1033+
ast: Ast,
1034+
src: []const u8,
1035+
path: ?[]const u8,
1036+
w: anytype,
1037+
) !void {
10331038
for (ast.errors) |err| {
10341039
const range = err.main_location.range(src);
1035-
std.debug.print("{s}:{}:{}: {s}\n", .{
1040+
try w.print("{s}:{}:{}: {s}\n", .{
10361041
path orelse "<stdin>",
10371042
range.start.row,
10381043
range.start.col,

src/html/Ast.zig

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,15 @@ pub fn cursor(ast: Ast, idx: u32) Cursor {
168168
return .{ .ast = ast, .idx = idx, .dir = .in };
169169
}
170170

171-
pub fn printErrors(ast: Ast, src: []const u8, path: ?[]const u8) void {
171+
pub fn printErrors(
172+
ast: Ast,
173+
src: []const u8,
174+
path: ?[]const u8,
175+
w: anytype,
176+
) !void {
172177
for (ast.errors) |err| {
173178
const range = err.main_location.range(src);
174-
std.debug.print("{s}:{}:{}: {s}\n", .{
179+
try w.print("{s}:{}:{}: {s}\n", .{
175180
path orelse "<stdin>",
176181
range.start.row,
177182
range.start.col,

0 commit comments

Comments
 (0)