Skip to content

Commit

Permalink
Print cause of exception. (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix authored Jun 23, 2024
1 parent 151dd84 commit aebaf48
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/sus/output/messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,20 @@ def error_prefix
[:errored, "⚠ "]
end

def error(error, identity)
def error(error, identity, prefix = error_prefix)
lines = error.message.split(/\r?\n/)

self.puts(:indent, *error_prefix, error.class, ": ", lines.shift)
self.puts(:indent, *prefix, error.class, ": ", lines.shift)

lines.each do |line|
self.puts(:indent, line)
end

self.write(Output::Backtrace.for(error, identity))

if cause = error.cause
self.error(cause, identity, ["Caused by ", :errored])
end
end

def inform_prefix
Expand Down

0 comments on commit aebaf48

Please sign in to comment.