summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorTom Black <[email protected]>2015-11-13 00:38:46 -0500
committerTom Black <[email protected]>2015-11-13 00:38:46 -0500
commitc578541d393dfa1536d564fd71f85f9a62c824c4 (patch)
treeff86908b0d7f0f5a397012601ae8fe8d04943ff4 /lib
parent92610f26fbeaa7bc3c52dbdca53fc9fec985a313 (diff)
downloadruby2d-c578541d393dfa1536d564fd71f85f9a62c824c4.tar.gz
ruby2d-c578541d393dfa1536d564fd71f85f9a62c824c4.zip
Cleaner exceptions
Diffstat (limited to 'lib')
-rw-r--r--lib/ruby2d/exceptions.rb10
1 files 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