Module: ActiveAgent::Providers::ExceptionHandler
- Extended by:
- ActiveSupport::Concern
- Included in:
- BaseProvider
- Defined in:
- lib/active_agent/providers/concerns/exception_handler.rb
Overview
Provides exception handling for provider operations.
This concern implements basic exception handling that allows agents to define custom error handling logic via rescue_from callbacks. The actual retry logic is now handled by the underlying provider gems (ruby-openai, anthropic-rb, etc.) which provide their own retry mechanisms.
Instance Method Summary collapse
-
#configure_exception_handler(exception_handler: nil) ⇒ void
Configures instance-level exception handling.
-
#rescue_with_handler(exception) ⇒ Object?
Bubbles up exceptions to the Agent’s rescue_from if a handler is defined.
-
#with_exception_handling { ... } ⇒ Object
Executes a block with exception handling.
Instance Method Details
#configure_exception_handler(exception_handler: nil) ⇒ void
This method returns an undefined value.
Configures instance-level exception handling.
42 43 44 |
# File 'lib/active_agent/providers/concerns/exception_handler.rb', line 42 def configure_exception_handler(exception_handler: nil) self.exception_handler = exception_handler end |
#rescue_with_handler(exception) ⇒ Object?
Bubbles up exceptions to the Agent’s rescue_from if a handler is defined.
This method delegates exception handling to the configured exception handler, allowing agents to define custom error handling logic.
67 68 69 |
# File 'lib/active_agent/providers/concerns/exception_handler.rb', line 67 def rescue_with_handler(exception) exception_handler&.call(exception) end |
#with_exception_handling { ... } ⇒ Object
Executes a block with exception handling.
54 55 56 57 58 |
# File 'lib/active_agent/providers/concerns/exception_handler.rb', line 54 def with_exception_handling(&block) yield rescue => exception rescue_with_handler(exception) || raise end |