Class: Raises::Subscriber
- Inherits:
-
Object
- Object
- Raises::Subscriber
- Defined in:
- lib/raises/subscriber.rb
Instance Method Summary collapse
-
#initialize ⇒ Subscriber
constructor
A new instance of Subscriber.
- #report(error, handled:, severity:, context:, source: nil) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ Subscriber
Returns a new instance of Subscriber.
9 10 11 12 |
# File 'lib/raises/subscriber.rb', line 9 def initialize @spool = build_spool @delivery = Delivery.new(post: method(:post), spool: @spool, warn: ->() { warn() }) end |
Instance Method Details
#report(error, handled:, severity:, context:, source: nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/raises/subscriber.rb', line 16 def report(error, handled:, severity:, context:, source: nil) return unless report? start notice = { env: env_name, revision: revision, handled: handled, error: { class: error.class.name, message: error..to_s, backtrace: Array(error.backtrace) }, context: json_safe(context_without_request(context).merge(severity: severity.to_s, source: source)), request: request_from(context) } @delivery.call(notice) rescue StandardError => e warn("raises subscriber failed: #{e.class}: #{e.}") end |
#start ⇒ Object
14 |
# File 'lib/raises/subscriber.rb', line 14 def start = tap { @spool&.start } |