const std = @import("std");

pub var errored = false;
pub var can_output = true;

const ErrorType = error{
    UnknownCharacter,
};

pub fn err(line: u32, comptime fmt: []const u8, args: anytype) !void {
    report(line, "unspecified", fmt, args);
}

pub fn report(line: u32, where: []const u8, comptime fmt: []const u8, args: anytype) !void {
    errored = true;

    // If we want to mute printing (completion), set can_output to false
    if (!can_output) {
        return;
    }

    var bw = std.io.bufferedWriter(std.io.getStdErr().writer());
    const stderr = bw.writer();
    try stderr.print("[line {d}] Error ({s}): ", .{ line, where });
    try stderr.print(fmt, args);
    _ = try stderr.write("\n");
    try bw.flush();
}