Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/active_agent/concerns/rescue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ module Rescue
include ActiveSupport::Rescuable

class_methods do
# Handles exceptions raised during GenerationJob execution.
#
# Called by GenerationJob#handle_exception_with_agent_class as a
# class-level fallback when no instance is available to handle the error.
#
# @param exception [Exception] the exception to handle
# @return [void]
def handle_exception(exception)
Rails.logger.error "[#{name}] #{exception.class}: #{exception.message}"
Rails.logger.error exception.backtrace&.first(10)&.join("\n") if exception.backtrace
end

# Finds and instruments the rescue handler for an exception.
#
# @param exception [Exception] the exception to handle
Expand Down