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.
class ExceptionalClass
def exceptional_method
cause = nil
begin
raise "Boom!"
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
No comments:
Post a Comment