File: sinatra_app.rb

package info (click to toggle)
ruby-exception-notification 4.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 808 kB
  • sloc: javascript: 7,680; ruby: 1,130; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 952 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'rubygems'
require 'bundler/setup'
require 'sinatra/base'
require 'exception_notification'

class SinatraApp < Sinatra::Base
  use ExceptionNotification::Rack,
    :email => {
      :email_prefix => "[Example] ",
      :sender_address => %{"notifier" <notifier@example.com>},
      :exception_recipients => %w{exceptions@example.com},
      :smtp_settings => { :address => "localhost", :port => 1025 }
    }

  get '/' do
    raise StandardError, "ERROR: #{params[:error]}" unless params[:error].blank?
    'Everything is fine! Now, lets break things clicking <a href="/?error=ops"> here </a>. Dont forget to see the emails at <a href="http://localhost:1080">mailcatcher</a> !'
  end

  get '/background_notification' do
    begin
      1/0
    rescue Exception => e
      ExceptionNotifier.notify_exception(e, :data => {:msg => "Cannot divide by zero!"})
    end
    'Check email at <a href="http://localhost:1080">mailcatcher</a>.'
  end
end