Class: Croaker::Swallower
- Inherits:
-
Object
- Object
- Croaker::Swallower
- Defined in:
- lib/croaker.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#note ⇒ Object
readonly
Returns the value of attribute note.
Instance Method Summary collapse
- #call ⇒ Object
- #capture(error) ⇒ Object
-
#initialize(error:, note:, logger: Rails.logger) ⇒ Swallower
constructor
A new instance of Swallower.
- #log(error:, note:) ⇒ Object
Constructor Details
#initialize(error:, note:, logger: Rails.logger) ⇒ Swallower
Returns a new instance of Swallower.
10 11 12 13 14 |
# File 'lib/croaker.rb', line 10 def initialize(error:, note:, logger: Rails.logger) @error = error @logger = logger @note = note end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
16 17 18 |
# File 'lib/croaker.rb', line 16 def error @error end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
16 17 18 |
# File 'lib/croaker.rb', line 16 def logger @logger end |
#note ⇒ Object (readonly)
Returns the value of attribute note.
16 17 18 |
# File 'lib/croaker.rb', line 16 def note @note end |
Instance Method Details
#call ⇒ Object
18 19 20 21 |
# File 'lib/croaker.rb', line 18 def call log(error: error, note: note) capture(error) end |
#capture(error) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/croaker.rb', line 33 def capture(error) if capturer capturer.capture_error(error) else logger.tagged("Croaker") do logger.info "Not capturing this error - no error capturing service registered." end end end |
#log(error:, note:) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/croaker.rb', line 23 def log(error:, note:) = "Unhandled error: [#{note}] [#{error.}]" += " #{error.backtrace.first}" if error.backtrace logger.tagged("Croaker") do logger.error end end |