Skip to content

Commit

Permalink
Change capture to be based on Exception, and improve backtrace printing
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksieger committed Mar 18, 2011
1 parent 8dba36c commit 2ce9295
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/main/ruby/jruby/rack/capture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# See the file LICENSE.txt for details.
#++

require 'jruby'

module JRuby::Rack
module Capture
module Base
Expand Down Expand Up @@ -37,7 +39,14 @@ def output

def capture
super
output.puts("\n--- Backtrace", *backtrace) if backtrace
if backtrace
if JRuby.runtime.instance_config.respond_to?(:trace_type)
full_trace = JRuby.runtime.instance_config.trace_type.print_backtrace(self)
else
full_trace = backtrace.join("\n")
end
output.puts("\n--- Backtrace", full_trace)
end
end
end

Expand Down
8 changes: 7 additions & 1 deletion src/main/ruby/jruby/rack/core_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@

require 'jruby/rack/capture'

class StandardError
def debug?
$DEBUG || !ENV['DEBUG'].nil?
end

class Exception
include JRuby::Rack::Capture::Base
include JRuby::Rack::Capture::Exception
include JRuby::Rack::Capture::Environment if debug?
include JRuby::Rack::Capture::RubyGems
include JRuby::Rack::Capture::Bundler
include JRuby::Rack::Capture::JRubyRackConfig
include JRuby::Rack::Capture::JavaEnvironment if debug?
end

class LoadError
Expand Down

0 comments on commit 2ce9295

Please sign in to comment.