mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Improve internal error handling output
This commit is contained in:
parent
543df88d39
commit
d663e82c36
1 changed files with 7 additions and 18 deletions
|
@ -103,7 +103,7 @@ module Spectator
|
||||||
# But if an exception occurs outside an example,
|
# But if an exception occurs outside an example,
|
||||||
# it's likely the fault of the test framework (Spectator).
|
# it's likely the fault of the test framework (Spectator).
|
||||||
# So we display a helpful error that could be reported and return non-zero.
|
# So we display a helpful error that could be reported and return non-zero.
|
||||||
display_error_stack(ex)
|
display_framework_error(ex)
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -147,22 +147,11 @@ module Spectator
|
||||||
# Displays a complete error stack.
|
# Displays a complete error stack.
|
||||||
# Prints an error and everything that caused it.
|
# Prints an error and everything that caused it.
|
||||||
# Stacktrace is included.
|
# Stacktrace is included.
|
||||||
private def display_error_stack(error) : Nil
|
private def display_framework_error(error) : Nil
|
||||||
puts
|
STDERR.puts
|
||||||
puts "Encountered an unexpected error in framework"
|
STDERR.puts "!> Spectator encountered an unexpected error."
|
||||||
# Loop while there's a cause for the error.
|
STDERR.puts "!> This is probably a bug and should be reported."
|
||||||
# Print each error in the stack.
|
STDERR.puts
|
||||||
loop do
|
error.inspect_with_backtrace(STDERR)
|
||||||
display_error(error)
|
|
||||||
error = error.cause
|
|
||||||
break unless error
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Display a single error and its stacktrace.
|
|
||||||
private def display_error(error) : Nil
|
|
||||||
puts
|
|
||||||
puts "Caused by: #{error.message}"
|
|
||||||
puts error.backtrace.join("\n")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue