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

Clarify output when printing nested exception traces #232

Merged
merged 1 commit into from Oct 24, 2017
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
17 changes: 13 additions & 4 deletions lib/rake/application.rb
Expand Up @@ -207,13 +207,22 @@ def display_error_message(ex) # :nodoc:
end

def display_exception_details(ex) # :nodoc:
seen = Thread.current[:rake_display_exception_details_seen] ||= []
return if seen.include? ex
seen << ex
display_exception_details_seen << ex

display_exception_message_details(ex)
display_exception_backtrace(ex)
display_exception_details(ex.cause) if has_cause?(ex)
display_cause_details(ex.cause) if has_cause?(ex)
end

def display_cause_details(ex) # :nodoc:
return if display_exception_details_seen.include? ex

trace "\nCaused by:"
display_exception_details(ex)
end

def display_exception_details_seen # :nodoc:
Thread.current[:rake_display_exception_details_seen] ||= []
end

def has_cause?(ex) # :nodoc:
Expand Down
1 change: 1 addition & 0 deletions test/test_rake_application.rb
Expand Up @@ -97,6 +97,7 @@ def test_display_exception_details_cause

assert_empty out

assert_match "Caused by:", err
assert_match "cause a", err
assert_match "cause b", err
end
Expand Down