Class: CanaryNotifier

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of CanaryNotifier.



4
5
6
# File 'lib/canary_notifier.rb', line 4

def initialize(app, options = {})
  @app, @options = app, options
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/canary_notifier.rb', line 8

def call(env)
  @app.call(env)
rescue Exception => e
  url = 'http://stark:[email protected]/notify'

  data = {}
  data["app"] = @options[:app_name] || "No Name"
  data["title"] = "#{e.class.name}: #{e.to_s}"

  data[:sections] = []

  backtrace = {}
  backtrace[:title] = 'Backtrace'
  backtrace[:body] = e.backtrace.join("\n")


  environ = {}
  environ[:title] = 'Environment'
  environ[:body] = env.to_a

  #data[:sections] << environ
  puts environment.inspect
  data[:sections] << backtrace

  RestClient.post url,  data.to_json
 
  raise e
end