Skip to content

Instantly share code, notes, and snippets.

@hashrocketeer
Created March 4, 2013 19:20
Show Gist options
  • Save hashrocketeer/5084682 to your computer and use it in GitHub Desktop.
Save hashrocketeer/5084682 to your computer and use it in GitHub Desktop.
App backtraces, even when testing javascript.
ApplicationController.class_eval do
rescue_from StandardError do |exception|
$stderr.puts ExceptionFormatter.summarize exception
raise
end
end
class ExceptionFormatter
extend Cucumber::Term::ANSIColor
def self.summarize(e)
unless Capybara.current_driver == :rack_test
relative_path_starts_at = Rails.root.to_s.size
trace = e.backtrace.grep(Regexp.new Rails.root.to_s).map {|line| line[relative_path_starts_at..-1] }
red "#{e}\n#{trace.join "\n" }\n"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment