Commits

Michael Granger committed 83cb6ec

Make exceptions rendered as comments include the backtrace if debugging comments are enabled.

  • Participants
  • Parent commits d5c44e8

Comments (0)

Files changed (3)

 tilt -v1.3.3
 sysexits -v1.0.2
 trollop -v1.16.2
-
+loggability -v0.5.0

File lib/inversion/renderstate.rb

 		when 'comment'
 			self.log.debug "  rendering error as a comment"
 			msg = "%s: %s" % [ exception.class.name, exception.message ]
+			if self.options[:debugging_comments]
+				exception.backtrace.each {|line| msg << "\n" << line }
+			end
 			return self.make_comment( msg )
 
 		when 'propagate'

File spec/inversion/renderstate_spec.rb

 			state.to_s.should == "<!-- NoMethodError: undefined method `klang' for nil:NilClass -->"
 		end
 
+		it "includes a backtrace when rendering errors in 'comment' mode with 'debugging_comments' enabled" do
+			node  = Inversion::Template::AttrTag.new( 'boom.klang' )
+			state = Inversion::RenderState.new( {}, :on_render_error => :comment, :debugging_comments => true )
+
+			state << node
+			output = state.to_s
+
+			output.should include( "<!-- NoMethodError: undefined method `klang' for nil:NilClass" )
+			output.should include( "#{__FILE__}:#{__LINE__ - 4}" )
+		end
+
 		it "re-raises errors while rendering appended nodes in 'propagate' mode" do
 			node  = Inversion::Template::AttrTag.new( 'boom.klang' )
 			state = Inversion::RenderState.new( {}, :on_render_error => :propagate )