Skip to content

Commit

Permalink
Outputs errors with colors
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienatplumbee committed Jun 9, 2015
1 parent 34cfc3f commit 5dc52cb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/minesweeper/console/game_loop.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'readline'
require 'minesweeper'
require 'rainbow'
require_relative 'prettyprinter/minefield_pretty_printer'
require_relative 'prettyprinter/theme/default_theme'
require_relative 'parser/command_parser'
Expand Down Expand Up @@ -29,14 +30,20 @@ def start
user_input = Readline.readline(PROMPT, true)
@command_parser.parse(user_input).execute
rescue Parser::UnsupportedCommandError, Parser::InvalidCommandParametersError => e
puts e.message
print_error(e)
rescue Minesweeper::Explosives::ExplosionError => e
puts e.message
print_error(e)
exit
end
end
end

def print_error(e)
puts '-' * 79
puts Rainbow(e.message).yellow.bright
puts '-' * 79
end

end
end
end
Expand Down

0 comments on commit 5dc52cb

Please sign in to comment.