Skip to content

Commit

Permalink
Hotfix: More resilient handling of API exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
krschacht committed Nov 24, 2024
1 parent e73019b commit 19fc3cb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/jobs/get_next_ai_message_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ def perform(user_id, message_id, assistant_id, attempt = 1)
GetNextAIMessageJob.broadcast_updated_message(@message, thinking: false)
GetNextAIMessageJob.set(wait: (attempt+1).seconds).perform_later(user_id, message_id, assistant_id, attempt+1)
else
error_text = nil
begin
error_text = e&.response&.dig(:body, "error", "message") rescue e&.response&.dig(:body)
error_text = if e.try(:response)
e&.response&.dig(:body, "error", "message") rescue e&.response&.dig(:body)
else
e.message
end
set_unexpected_error(msg&.slice(0...1500), error_text)
wrap_up_the_message
Expand Down

0 comments on commit 19fc3cb

Please sign in to comment.