From cef669e15e01d0675d0d26727d0693b7c0a1c09f Mon Sep 17 00:00:00 2001 From: Glenn Date: Tue, 24 Oct 2023 16:00:12 +0200 Subject: [PATCH] fix: improve fzf error handling --- src/fzf.cr | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/fzf.cr b/src/fzf.cr index db2738d..860d8df 100644 --- a/src/fzf.cr +++ b/src/fzf.cr @@ -11,8 +11,17 @@ module GX error = STDERR process = Process.new("fzf", ["--ansi"], input: input, output: output, error: error) - unless process.wait.success? - STDERR.puts "Error executing fzf: #{error.to_s.strip}".colorize(:red) + status = process.wait + case status.exit_code + when 0 + when 1 + STDERR.puts "No match".colorize(:red) + exit(1) + when 130 + STDERR.puts "Interrupted".colorize(:red) + exit(1) + else # includes retcode = 2 (error) + STDERR.puts "Error executing fzf: #{error.to_s.strip} (#{status.exit_code})".colorize(:red) exit(1) end