Skip to content

Instantly share code, notes, and snippets.

@dgilperez
Forked from tddium/capybara_debug.rb
Created May 3, 2012 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgilperez/2585251 to your computer and use it in GitHub Desktop.
Save dgilperez/2585251 to your computer and use it in GitHub Desktop.
Trap Capybara Stack Trace
### 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