refactor(cli): update errors.zig to use io.zig

Update errors.zig to use consolidated io module:
- Replace colors.printError with io.printError
- Replace colors.printWarning with io.printWarning
- Replace colors.printInfo with io.printInfo

All tests pass.
This commit is contained in:
Jeremie Fraeys 2026-03-04 21:36:00 -05:00
parent 6c192e5144
commit 02b64be999
No known key found for this signature in database

View file

@ -1,5 +1,5 @@
const std = @import("std");
const colors = @import("utils/colors.zig");
const io = @import("utils/io.zig");
const crypto = @import("utils/crypto.zig");
/// User-friendly error types for CLI
@ -143,18 +143,18 @@ pub const ErrorHandler = struct {
const message = ErrorMessages.getMessage(err);
const suggestion = ErrorMessages.getSuggestion(err);
colors.printError("Error: {s}\n", .{message});
io.printError("Error: {s}\n", .{message});
if (context) |ctx| {
colors.printWarning("Context: {s}\n", .{ctx});
io.printWarning("Context: {s}\n", .{ctx});
}
if (suggestion) |sug| {
colors.printInfo("Suggestion: {s}\n", .{sug});
io.printInfo("Suggestion: {s}\n", .{sug});
}
if (ErrorMessages.isUserFixable(err)) {
colors.printInfo("This error can be fixed by updating your configuration.\n", .{});
io.printInfo("This error can be fixed by updating your configuration.\n", .{});
}
}
@ -169,16 +169,16 @@ pub const ErrorHandler = struct {
const suggestion = ErrorMessages.getSuggestion(err);
const is_fixable = ErrorMessages.isUserFixable(err);
colors.printError("Error in '{s}': {s}\n", .{ command, message });
io.printError("Error in '{s}': {s}\n", .{ command, message });
if (suggestion) |sug| {
colors.printInfo("Suggestion: {s}\n", .{sug});
io.printInfo("Suggestion: {s}\n", .{sug});
}
if (is_fixable) {
colors.printInfo("This is a user-fixable issue.\n", .{});
io.printInfo("This is a user-fixable issue.\n", .{});
} else {
colors.printWarning("If this persists, check server logs or contact support.\n", .{});
io.printWarning("If this persists, check server logs or contact support.\n", .{});
}
// Exit with appropriate code