Skip to content

Commit

Permalink
Monkey-patch Sinatra to include method and path in the Sinatra::NotFo…
Browse files Browse the repository at this point in the history
…und exception message.
  • Loading branch information
stefansundin committed Sep 1, 2019
1 parent 59905ce commit 2ee7793
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions config/application.rb
Expand Up @@ -8,6 +8,21 @@
app_path = File.expand_path("../..", __FILE__)
Dir["#{app_path}/lib/*.rb"].each { |f| require f }

# Expose the request path in the exception message for Sinatra::NotFound
# This makes it easier to scan the list of errors in Airbrake to see what paths causes 404 errors
# https://github.com/sinatra/sinatra/pull/1566
module Sinatra
class Base
def route_missing
if @app
forward
else
raise NotFound, "#{request.request_method} #{request.path_info}"
end
end
end
end

# uncomment to get production error pages in development
# set :environment, :production

Expand Down

0 comments on commit 2ee7793

Please sign in to comment.