From c0d44667821fc43c6460a83610a8516d5e9f8228 Mon Sep 17 00:00:00 2001 From: Sunrise Date: Sat, 11 May 2024 12:02:19 +0800 Subject: [PATCH] Normalize the error outputs --- src/mockgpt/commands.cr | 6 ++---- src/mockgpt/options.cr | 2 +- src/mockgpt/utils.cr | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/mockgpt/commands.cr b/src/mockgpt/commands.cr index 1a1bc69..09e8900 100644 --- a/src/mockgpt/commands.cr +++ b/src/mockgpt/commands.cr @@ -40,8 +40,7 @@ module Commands puts "Upgrade succeeded!" else File.rename(tempPath, exePath) - STDERR.puts "Upgrade failed. Please try again." - exit 1 + abort "Upgrade failed. Please try again." end {% else %} url = "https://github.com/yanecc/MockGPT/releases/download/latest/mockgpt-" @@ -70,8 +69,7 @@ module Commands {% else %} File.delete tempPath if File.exists? tempPath {% end %} - STDERR.puts "Upgrade failed. Please try again." - exit 1 + abort "Upgrade failed. Please try again." end {% end %} end diff --git a/src/mockgpt/options.cr b/src/mockgpt/options.cr index ebaedd6..7a66215 100644 --- a/src/mockgpt/options.cr +++ b/src/mockgpt/options.cr @@ -31,7 +31,7 @@ OptionParser.parse do |parser| parser.unknown_args do |args, _| if args.size > 2 STDERR.puts "Too many arguments: #{args}", parser - exit(1) + exit 1 end case args[0]? || "all" when "all" diff --git a/src/mockgpt/utils.cr b/src/mockgpt/utils.cr index 00eef38..35e574f 100644 --- a/src/mockgpt/utils.cr +++ b/src/mockgpt/utils.cr @@ -6,8 +6,7 @@ module Utils if response.status_code == 200 return response.body.to_s.match(pattern).try &.[1] || abort "Failed to match available versions." else - puts "Failed to get latest version: #{response.status_message}" - exit(1) + abort "Failed to get latest version: #{response.status_message}" end end