From c578541d393dfa1536d564fd71f85f9a62c824c4 Mon Sep 17 00:00:00 2001 From: Tom Black Date: Fri, 13 Nov 2015 00:38:46 -0500 Subject: Cleaner exceptions --- lib/ruby2d/exceptions.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ruby2d/exceptions.rb b/lib/ruby2d/exceptions.rb index 6f8416b..9ea90c7 100644 --- a/lib/ruby2d/exceptions.rb +++ b/lib/ruby2d/exceptions.rb @@ -2,11 +2,15 @@ module Ruby2D class Error < StandardError + def colorize(msg, c); "\e[#{c}m#{msg}\e[0m" end + def error(msg); colorize(msg, '4;31') end + def bold(msg); colorize(msg, '1') end + def initialize(msg) super(msg) - puts msg - puts "Occurred in:" - puts " " + caller.last, "\n" + puts error("\nRuby 2D Error:") << " " << msg + puts bold("Occurred in:") + puts bold(" " + caller.last), "\n" end end end -- cgit v1.2.3