Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

renderErrorMessage

Used for generic colored errors/warnings/notes, more context-specific error messages are handled elsewhere.

utils.renderErrorMessage
pub fn renderErrorMessage(t: Io.Terminal, msg_type: ErrorMessageType, comptime format: []const u8, args: anytype) !void

File

Code

pub fn renderErrorMessage(t: Io.Terminal, msg_type: ErrorMessageType, comptime format: []const u8, args: anytype) !void {
    const writer = t.writer;
    switch (msg_type) {
        .err => {
            try t.setColor(.bold);
            try t.setColor(.red);
            try writer.writeAll("error: ");
        },
        .warning => {
            try t.setColor(.bold);
            try t.setColor(.yellow);
            try writer.writeAll("warning: ");
        },
        .note => {
            try t.setColor(.reset);
            try t.setColor(.cyan);
            try writer.writeAll("note: ");
        },
    }
    try t.setColor(.reset);
    if (msg_type == .err) {
        try t.setColor(.bold);
    }
    try writer.print(format, args);
    try writer.writeByte('\n');
    try t.setColor(.reset);
}