From 71c4fc2e6fa1d6f70c85bf525842d6888d1ffa46 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Tue, 24 Dec 2024 17:53:35 +0800 Subject: [PATCH] refactor: use v0.4 `Error` type for error handling --- chmod.yazi/init.lua | 2 +- git.yazi/init.lua | 2 +- lsar.yazi/init.lua | 4 ++-- mactag.yazi/init.lua | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/chmod.yazi/init.lua b/chmod.yazi/init.lua index bfb0970..183c31e 100644 --- a/chmod.yazi/init.lua +++ b/chmod.yazi/init.lua @@ -30,7 +30,7 @@ return { if not status or not status.success then ya.notify { title = "Chmod", - content = string.format("Chmod with selected files failed, exit code %s", status and status.code or err), + content = string.format("Chmod on selected files failed, error: %s", status and status.code or err), level = "error", timeout = 5, } diff --git a/git.yazi/init.lua b/git.yazi/init.lua index 7ea5622..64c3e8e 100644 --- a/git.yazi/init.lua +++ b/git.yazi/init.lua @@ -175,7 +175,7 @@ local function fetch(_, job) :stdout(Command.PIPED) :output() if not output then - ya.err("Cannot spawn git command, error code " .. tostring(err)) + ya.err("Cannot spawn git command, error: " .. err) return 0 end diff --git a/lsar.yazi/init.lua b/lsar.yazi/init.lua index 06fec62..2eefea6 100644 --- a/lsar.yazi/init.lua +++ b/lsar.yazi/init.lua @@ -1,9 +1,9 @@ local M = {} function M:peek(job) - local child, code = Command("lsar"):arg(tostring(job.file.url)):stdout(Command.PIPED):spawn() + local child, err = Command("lsar"):arg(tostring(job.file.url)):stdout(Command.PIPED):spawn() if not child then - return ya.err("spawn `lsar` command returns " .. tostring(code)) + return ya.err("spawn `lsar` command failed: " .. err) end -- Skip the first line which is the archive file itself diff --git a/mactag.yazi/init.lua b/mactag.yazi/init.lua index 712559d..3c0bef1 100644 --- a/mactag.yazi/init.lua +++ b/mactag.yazi/init.lua @@ -43,7 +43,7 @@ local function fetch(_, job) local output, err = Command("tag"):args(paths):stdout(Command.PIPED):output() if not output then - return ya.err("Cannot spawn tag command, error code " .. tostring(err)) + return ya.err("Cannot spawn tag command, error: " .. err) end local i, tags = 1, {}