Skip to content

Commit

Permalink
Refactored error handling to output response.body on Crest::RequestFa…
Browse files Browse the repository at this point in the history
…iled
  • Loading branch information
kojix2 committed Mar 28, 2024
1 parent 4b6aeaa commit 6c55476
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/deepl/app.cr
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ module DeepL
raise ArgumentError.new("Invalid action: #{option.action}")
end
rescue ex
if DeepLError.debug
STDERR.puts "[deepl-cli] ERROR: #{ex.class} #{ex.message}\n#{ex.backtrace.join("\n")}"
else
STDERR.puts "[deepl-cli] ERROR: #{ex.class} #{ex.message}"
end
error_message = "[deepl-cli] ERROR: #{ex.class} #{ex.message}"
error_message += "\n#{ex.response.body}" if ex.is_a?(Crest::RequestFailed)
error_message += "\n#{ex.backtrace.join("\n")}" if DeepLError.debug
STDERR.puts error_message
exit(1)
end

Expand Down

0 comments on commit 6c55476

Please sign in to comment.