Module: SecApi::CallbackHelper
- Included in:
- Client, Middleware::Instrumentation
- Defined in:
- lib/sec_api/callback_helper.rb
Overview
Shared helper methods for callback invocation and error handling.
This module provides consistent callback error logging across all middleware and client code. All callback invocations should use this module’s helpers to ensure consistent structured logging when callbacks fail.
Instance Method Summary collapse
-
#log_callback_error(callback_name, error, config = nil) ⇒ void
Logs callback errors to the configured logger with structured JSON format.
Instance Method Details
#log_callback_error(callback_name, error, config = nil) ⇒ void
This method returns an undefined value.
Logs callback errors to the configured logger with structured JSON format.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/sec_api/callback_helper.rb', line 30 def log_callback_error(callback_name, error, config = nil) # Use instance variable @config if config not passed cfg = config || (defined?(@config) ? @config : nil) || (defined?(@_config) ? @_config : nil) return unless cfg&.logger begin cfg.logger.error do { event: "secapi.callback_error", callback: callback_name, error_class: error.class.name, error_message: error. }.to_json end rescue # Don't let logging errors break anything end end |