Class: ExceptionsToSlack::Notifier

Inherits:
Object
  • Object
show all
Defined in:
lib/exceptions_to_slack/notifier.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Notifier

Returns a new instance of Notifier.



5
6
7
8
9
10
11
12
# File 'lib/exceptions_to_slack/notifier.rb', line 5

def initialize(app, options = {})
  @app = app
  @notifier = Slack::Notifier.new(url(options))
  @notifier.channel = options[:channel] || raise("Channel is required")
  @notifier.username = options[:user] || "Notifier"
  @ignore = options[:ignore]
  @additional_parameters = options[:additional_parameters] || {}
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
# File 'lib/exceptions_to_slack/notifier.rb', line 14

def call(env)
  @app.call(env)
rescue Exception => exception
  send_to_slack(exception) unless @ignore && @ignore.match(exception.to_s)
  raise exception
end