diff --git a/src/spectator.cr b/src/spectator.cr index 060f3c2..5b18701 100644 --- a/src/spectator.cr +++ b/src/spectator.cr @@ -83,10 +83,15 @@ 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. - puts - puts "Encountered an unexpected error in framework" - puts ex.message - puts ex.backtrace.join("\n") + display_error(ex) exit(1) end + + # Displays an error message. + private def self.display_error(error) + puts + puts "Encountered an unexpected error in framework" + puts error.message + puts error.backtrace.join("\n") + end end