mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Display cause of errors
This commit is contained in:
parent
c0be260f98
commit
e0273d660c
1 changed files with 18 additions and 4 deletions
|
@ -93,7 +93,7 @@ module Spectator
|
|||
# But if an exception occurs outside an example,
|
||||
# it's likely the fault of the test framework (Spectator).
|
||||
# So we display a helpful error that could be reported and return non-zero.
|
||||
display_error(ex)
|
||||
display_error_stack(ex)
|
||||
exit(1)
|
||||
end
|
||||
|
||||
|
@ -129,11 +129,25 @@ module Spectator
|
|||
CommandLineArgumentsConfigSource.new.apply_to(@@config_builder)
|
||||
end
|
||||
|
||||
# Displays an error message.
|
||||
private def self.display_error(error) : Nil
|
||||
# Displays a complete error stack.
|
||||
# Prints an error and everything that caused it.
|
||||
# Stacktrace is included.
|
||||
private def self.display_error_stack(error) : Nil
|
||||
puts
|
||||
puts "Encountered an unexpected error in framework"
|
||||
puts error.message
|
||||
# Loop while there's a cause for the error.
|
||||
# Print each error in the stack.
|
||||
loop do
|
||||
display_error(error)
|
||||
error = error.cause
|
||||
break unless error
|
||||
end
|
||||
end
|
||||
|
||||
# Display a single error and its stacktrace.
|
||||
private def self.display_error(error) : Nil
|
||||
puts
|
||||
puts "Caused by: #{error.message}"
|
||||
puts error.backtrace.join("\n")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue