Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "see full crash log" line from crash log #402

Merged
merged 1 commit into from Mar 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/nanoc/cli/error_handler.rb
Expand Up @@ -293,13 +293,15 @@ def write_compilation_stack(stream, error, params = {})
end

def write_stack_trace(stream, error, params = {})
is_verbose = params.fetch(:verbose, false)

write_section_header(stream, 'Stack trace', params)

count = params[:verbose] ? -1 : 10
count = is_verbose ? -1 : 10
error.backtrace[0...count].each_with_index do |item, index|
stream.puts " #{index}. #{item}"
end
if error.backtrace.size > count
if !is_verbose && error.backtrace.size > count
stream.puts " ... #{error.backtrace.size - count} more lines omitted. See full crash log for details."
end
end
Expand Down
32 changes: 32 additions & 0 deletions test/cli/test_error_handler.rb
Expand Up @@ -29,4 +29,36 @@ def test_resolution_for_with_not_load_error
assert_nil @handler.send(:resolution_for, error)
end

def test_write_stack_trace_verbose
error = new_error(20)

stream = StringIO.new
@handler.send(:write_stack_trace, stream, error, :verbose => false)
assert_match(/See full crash log for details./, stream.string)

stream = StringIO.new
@handler.send(:write_stack_trace, stream, error, :verbose => false)
assert_match(/See full crash log for details./, stream.string)

stream = StringIO.new
@handler.send(:write_stack_trace, stream, error, :verbose => true)
refute_match(/See full crash log for details./, stream.string)
end

def new_error(amount_factor)
backtrace_generator = lambda do |af|
if af == 0
raise "finally!"
else
backtrace_generator.call(af - 1)
end
end

begin
backtrace_generator.call(amount_factor)
rescue => e
return e
end
end

end