class ExceptionalClass def exceptional_method cause = nil begin raise "Boom!" # RuntimeError raised rescue => e raise StandardError, "Ka-pow!" end end end def setup size 500, 120 background 50, 50, 200 f = createFont("Arial", 16, true) text_font(f, 16) fill(255, 0, 0) begin ExceptionalClass.new.exceptional_method rescue Exception => e exception = "Caught Exception: #{e.message} [#{e.class}]" cause = "Caused by : #{e.cause.message} [#{e.cause.class}]" text(exception, 20, 30) fill(255, 255, 0) text(cause, 20, 60) end end
Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0
Saturday, 10 May 2014
Enhanced exception handling in ruby 2.1.0
This one was promoted by headius (Charles Nutter), so guaranteed to work with jruby-9000? Get access to the cause of the original exception, when re-thrown.
Labels:
exception handling,
jruby-9000,
ruby-processing
Subscribe to:
Post Comments (Atom)
Followers
Blog Archive
-
▼
2014
(79)
-
▼
May
(7)
- Somewhat optimised version of trefoil sketch
- Extending ruby-processing with built in jruby exte...
- Creating a jruby extension as a gem
- Lambda clock (featuring DegLut tables now only in ...
- Latest processing update
- Enhanced exception handling in ruby 2.1.0
- Exploring ruby-2.1.2 syntax in ruby-processing
-
▼
May
(7)
About Me
- monkstone
- I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2
No comments:
Post a Comment