-
Notifications
You must be signed in to change notification settings - Fork 5
/
example.rb
38 lines (32 loc) · 891 Bytes
/
example.rb
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
29
30
31
32
33
34
35
36
37
38
require 'sinatra'
require 'rollbar'
set :environment, :production
configure do
Rollbar.configure do |config|
config.access_token = 'aaaabbbbccccddddeeeeffff00001111'
config.environment = Sinatra::Base.environment
config.framework = "Sinatra: #{Sinatra::VERSION}"
config.root = Dir.pwd
end
end
# Adapter around the default RequestDataExtractor
class RequestDataExtractor
include Rollbar::RequestDataExtractor
def from_rack(env)
extract_request_data_from_rack(env).merge({
:route => env["PATH_INFO"]
})
end
end
error do
# To send an arbitrary message:
Rollbar.report_message("Something went wrong")
# To send the exception traceback:
request_data = RequestDataExtractor.new.from_rack(env)
Rollbar.report_exception(env['sinatra.error'], request_data)
"error"
end
get '/' do
raise RuntimeError, "custom message"
"Hello world!"
end