refactor: eliminate generic InvalidArgument errors
InvalidArgument is too generic and makes tracking the source of the error potentially difficult.
This commit is contained in:
parent
4ec66be2d4
commit
a5849a7dab
10 changed files with 42 additions and 42 deletions
|
@ -300,7 +300,7 @@ pub fn Create(options: type) type {
|
|||
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||
var egc: u32 = 0;
|
||||
if (!try ctx.args.match(.{tp.extract(&egc)}))
|
||||
return error.InvalidArgument;
|
||||
return error.InvalidFileBrowserInsertCodePointArgument;
|
||||
self.complete_trigger_count = 0;
|
||||
var buf: [32]u8 = undefined;
|
||||
const bytes = try input.ucs32_to_utf8(&[_]u32{egc}, &buf);
|
||||
|
@ -312,7 +312,7 @@ pub fn Create(options: type) type {
|
|||
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
||||
var bytes: []const u8 = undefined;
|
||||
if (!try ctx.args.match(.{tp.extract(&bytes)}))
|
||||
return error.InvalidArgument;
|
||||
return error.InvalidFileBrowserInsertBytesArgument;
|
||||
self.complete_trigger_count = 0;
|
||||
try self.file_path.appendSlice(bytes);
|
||||
self.update_mini_mode_text();
|
||||
|
|
|
@ -171,7 +171,7 @@ const cmds = struct {
|
|||
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||
var egc: u32 = 0;
|
||||
if (!try ctx.args.match(.{tp.extract(&egc)}))
|
||||
return error.InvalidArgument;
|
||||
return error.InvalidFindInsertCodePointArgument;
|
||||
self.insert_code_point(egc) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||
self.update_mini_mode_text();
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ const cmds = struct {
|
|||
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
||||
var bytes: []const u8 = undefined;
|
||||
if (!try ctx.args.match(.{tp.extract(&bytes)}))
|
||||
return error.InvalidArgument;
|
||||
return error.InvalidFindInsertBytesArgument;
|
||||
self.insert_bytes(bytes) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||
self.update_mini_mode_text();
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ const cmds = struct {
|
|||
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||
var egc: u32 = 0;
|
||||
if (!try ctx.args.match(.{tp.extract(&egc)}))
|
||||
return error.InvalidArgument;
|
||||
return error.InvalidFindInFilesInsertCodePointArgument;
|
||||
self.insert_code_point(egc) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||
self.update_mini_mode_text();
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ const cmds = struct {
|
|||
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
||||
var bytes: []const u8 = undefined;
|
||||
if (!try ctx.args.match(.{tp.extract(&bytes)}))
|
||||
return error.InvalidArgument;
|
||||
return error.InvalidFindInFilesInsertBytesArgument;
|
||||
self.insert_bytes(bytes) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||
self.update_mini_mode_text();
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ const cmds = struct {
|
|||
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||
var keypress: usize = 0;
|
||||
if (!try ctx.args.match(.{tp.extract(&keypress)}))
|
||||
return error.InvalidArgument;
|
||||
return error.InvalidGotoInsertCodePointArgument;
|
||||
switch (keypress) {
|
||||
'0'...'9' => self.insert_char(@intCast(keypress)),
|
||||
else => {},
|
||||
|
@ -124,7 +124,7 @@ const cmds = struct {
|
|||
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
||||
var bytes: []const u8 = undefined;
|
||||
if (!try ctx.args.match(.{tp.extract(&bytes)}))
|
||||
return error.InvalidArgument;
|
||||
return error.InvalidGotoInsertBytesArgument;
|
||||
self.insert_bytes(bytes);
|
||||
self.update_mini_mode_text();
|
||||
self.goto();
|
||||
|
|
|
@ -32,7 +32,7 @@ const Operation = enum {
|
|||
pub fn create(allocator: Allocator, ctx: command.Context) !struct { tui.Mode, tui.MiniMode } {
|
||||
var right: bool = true;
|
||||
const select = if (tui.get_active_editor()) |editor| if (editor.get_primary().selection) |_| true else false else false;
|
||||
_ = ctx.args.match(.{tp.extract(&right)}) catch return error.InvalidArgument;
|
||||
_ = ctx.args.match(.{tp.extract(&right)}) catch return error.InvalidMoveToCharArgument;
|
||||
const self: *Self = try allocator.create(Self);
|
||||
self.* = .{
|
||||
.allocator = allocator,
|
||||
|
@ -92,9 +92,9 @@ const cmds = struct {
|
|||
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||
var code_point: u32 = 0;
|
||||
if (!try ctx.args.match(.{tp.extract(&code_point)}))
|
||||
return error.InvalidArgument;
|
||||
return error.InvalidMoveToCharInsertCodePointArgument;
|
||||
var buf: [6]u8 = undefined;
|
||||
const bytes = input.ucs32_to_utf8(&[_]u32{code_point}, &buf) catch return error.InvalidArgument;
|
||||
const bytes = input.ucs32_to_utf8(&[_]u32{code_point}, &buf) catch return error.InvalidMoveToCharCodePoint;
|
||||
return self.execute_operation(command.fmt(.{buf[0..bytes]}));
|
||||
}
|
||||
pub const mini_mode_insert_code_point_meta = .{ .arguments = &.{.integer} };
|
||||
|
@ -102,7 +102,7 @@ const cmds = struct {
|
|||
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
||||
var bytes: []const u8 = undefined;
|
||||
if (!try ctx.args.match(.{tp.extract(&bytes)}))
|
||||
return error.InvalidArgument;
|
||||
return error.InvalidMoveToCharInsertBytesArgument;
|
||||
return self.execute_operation(ctx);
|
||||
}
|
||||
pub const mini_mode_insert_bytes_meta = .{ .arguments = &.{.string} };
|
||||
|
|
|
@ -309,7 +309,7 @@ const cmds = struct {
|
|||
pub fn overlay_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||
var egc: u32 = 0;
|
||||
if (!try ctx.args.match(.{tp.extract(&egc)}))
|
||||
return error.InvalidArgument;
|
||||
return error.InvalidOpenRecentInsertCodePointArgument;
|
||||
self.insert_code_point(egc) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||
}
|
||||
pub const overlay_insert_code_point_meta = .{ .arguments = &.{.integer} };
|
||||
|
@ -317,7 +317,7 @@ const cmds = struct {
|
|||
pub fn overlay_insert_bytes(self: *Self, ctx: Ctx) Result {
|
||||
var bytes: []const u8 = undefined;
|
||||
if (!try ctx.args.match(.{tp.extract(&bytes)}))
|
||||
return error.InvalidArgument;
|
||||
return error.InvalidOpenRecentInsertBytesArgument;
|
||||
self.insert_bytes(bytes) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||
}
|
||||
pub const overlay_insert_bytes_meta = .{ .arguments = &.{.string} };
|
||||
|
|
|
@ -446,7 +446,7 @@ pub fn Create(options: type) type {
|
|||
pub fn overlay_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||
var egc: u32 = 0;
|
||||
if (!try ctx.args.match(.{tp.extract(&egc)}))
|
||||
return error.InvalidArgument;
|
||||
return error.InvalidPaletteInsertCodePointArgument;
|
||||
self.insert_code_point(egc) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||
}
|
||||
pub const overlay_insert_code_point_meta = .{ .arguments = &.{.integer} };
|
||||
|
@ -454,7 +454,7 @@ pub fn Create(options: type) type {
|
|||
pub fn overlay_insert_bytes(self: *Self, ctx: Ctx) Result {
|
||||
var bytes: []const u8 = undefined;
|
||||
if (!try ctx.args.match(.{tp.extract(&bytes)}))
|
||||
return error.InvalidArgument;
|
||||
return error.InvalidPaletteInsertBytesArgument;
|
||||
self.insert_bytes(bytes) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||
}
|
||||
pub const overlay_insert_bytes_meta = .{ .arguments = &.{.string} };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue