From 4d680430455cf3342d298d2ec277127650748c60 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sun, 24 May 2020 15:18:57 +0200 Subject: Add callback to command request for error handling --- src/Command.zig | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/Command.zig') diff --git a/src/Command.zig b/src/Command.zig index 58c58d3..0632e5c 100644 --- a/src/Command.zig +++ b/src/Command.zig @@ -117,10 +117,21 @@ const str_to_read_fn = [_]Definition{ }; // zig fmt: on +pub const Error = error{ + NoCommand, + UnknownCommand, + NotEnoughArguments, + TooManyArguments, + Overflow, + InvalidCharacter, + InvalidDirection, + OutOfMemory, +}; + impl: ImplFn, arg: Arg, -pub fn init(args: []const []const u8, allocator: *std.mem.Allocator) !Self { +pub fn init(args: []const []const u8, allocator: *std.mem.Allocator) Error!Self { if (args.len == 0) return error.NoCommand; const name = args[0]; -- cgit v1.2.3