fix: improve fzf error handling
This commit is contained in:
parent
67cd9ae964
commit
cef669e15e
1 changed files with 11 additions and 2 deletions
13
src/fzf.cr
13
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue