Class: Bellman::Handlers::Handler
- Inherits:
-
Object
- Object
- Bellman::Handlers::Handler
- Defined in:
- lib/bellman/handlers/handler.rb
Overview
Main interface for interacting with all of the registerd handlers
Instance Attribute Summary collapse
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
Instance Method Summary collapse
-
#handle(error, severity: :error, trace_id: nil, objects: nil, data: nil, include_backtrace: false, handlers: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists.
-
#initialize(handlers: nil) ⇒ Handler
constructor
A new instance of Handler.
Constructor Details
#initialize(handlers: nil) ⇒ Handler
Returns a new instance of Handler.
9 10 11 12 |
# File 'lib/bellman/handlers/handler.rb', line 9 def initialize(handlers: nil) handlers ||= Bellman.config.handlers @handlers = process_handlers_config(handlers) end |
Instance Attribute Details
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
7 8 9 |
# File 'lib/bellman/handlers/handler.rb', line 7 def handlers @handlers end |
Instance Method Details
#handle(error, severity: :error, trace_id: nil, objects: nil, data: nil, include_backtrace: false, handlers: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bellman/handlers/handler.rb', line 15 def handle(error, severity: :error, trace_id: nil, objects: nil, data: nil, include_backtrace: false, handlers: nil) severity = handle_severity(severity) handlers = if handlers.present? process_handlers_config(handlers) else @handlers end handled = false handlers.each do |handler| next unless handler[:severities].include?(severity) raise "No handler specificed in #{handler}" unless handler[:handler] handler[:handler].handle( error, severity:, trace_id:, objects:, data:, include_backtrace: ) handled = true end handled end |