Skip to content

Instantly share code, notes, and snippets.

@ahmetabdi
Forked from tddium/capybara_debug.rb
Created April 8, 2014 08:15
Show Gist options
  • Save ahmetabdi/10101240 to your computer and use it in GitHub Desktop.
Save ahmetabdi/10101240 to your computer and use it in GitHub Desktop.
### Show stack trace for 500 errors
### (adapted from https://gist.github.com/1079020)
# Given an application, yield to a block to handle exceptions
class ExceptionRaiserApp
def initialize(app)
@app = app
end
def call(env)
@app.call(env)
rescue => e
backtrace = [ "#{'*'*20} #{e.to_s} #{'*'*20}",
'',
e.message,
'',
Rails.backtrace_cleaner.clean(e.backtrace, :silent),
'',
'*'*80,
'' ].join("\n\t")
# log the backtrace
Rails.logger.error backtrace
# re-raise so capybara gets a 500 and knows what's up
raise e
end
end
Capybara.app = ExceptionRaiserApp.new(MyApp::Application)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment