From 21175add57ce075ef441826db5c6a7c0b95df378 Mon Sep 17 00:00:00 2001 From: Neil Jobbins <3514122+TheRealNeil@users.noreply.github.com> Date: Sat, 7 Feb 2026 19:37:23 -0800 Subject: [PATCH] Add handle_exception method to log errors during GenerationJob execution --- lib/active_agent/concerns/rescue.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/active_agent/concerns/rescue.rb b/lib/active_agent/concerns/rescue.rb index 5f3938ba..86600b1b 100644 --- a/lib/active_agent/concerns/rescue.rb +++ b/lib/active_agent/concerns/rescue.rb @@ -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