2019-09-18 18:59:11 +00:00
|
|
|
const std = @import("std");
|
|
|
|
|
2019-09-20 16:16:55 +00:00
|
|
|
pub fn report(line: usize, where: []const u8, ctx_opt: ?[]const u8, message: []const u8) void {
|
|
|
|
if (ctx_opt) |ctx| {
|
2020-04-01 19:09:52 +00:00
|
|
|
std.debug.warn("[line {}] Error{} on {}: {}", .{ line, where, ctx, message });
|
2019-09-20 16:16:55 +00:00
|
|
|
} else {
|
2020-04-01 19:09:52 +00:00
|
|
|
std.debug.warn("[line {}] Error{}: {}", .{ line, where, message });
|
2019-09-20 16:16:55 +00:00
|
|
|
}
|
2019-09-18 18:59:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn reportN(line: usize, message: []const u8) void {
|
|
|
|
report(line, "", message);
|
|
|
|
}
|
|
|
|
|
2020-07-23 19:42:49 +00:00
|
|
|
pub fn reportFmt(line: usize, ctx_opt: ?[]const u8, comptime fmt: []const u8, args: anytype) void {
|
2019-09-20 16:16:55 +00:00
|
|
|
if (ctx_opt) |ctx| {
|
2020-04-01 19:09:52 +00:00
|
|
|
std.debug.warn("[line {}] Error on {}", .{ line, ctx });
|
2019-09-20 16:16:55 +00:00
|
|
|
} else {
|
2020-04-01 19:09:52 +00:00
|
|
|
std.debug.warn("[line {}] Error", .{line});
|
2019-09-20 16:16:55 +00:00
|
|
|
}
|
|
|
|
|
2019-09-18 18:59:11 +00:00
|
|
|
std.debug.warn(fmt, args);
|
2020-04-01 19:09:52 +00:00
|
|
|
std.debug.warn("\n", .{});
|
2019-09-18 18:59:11 +00:00
|
|
|
}
|