[macruby-changes] [4699] DietRB/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Oct 8 04:01:31 PDT 2010
Revision: 4699
http://trac.macosforge.org/projects/ruby/changeset/4699
Author: eloy.de.enige at gmail.com
Date: 2010-10-08 04:01:29 -0700 (Fri, 08 Oct 2010)
Log Message:
-----------
Keep the last raised exception around in $EXCEPTION ($e).
Thanks to Mislav Marohni?\196?\135 for the good suggestion
From: Eloy Duran <eloy.de.enige at gmail.com>
Modified Paths:
--------------
DietRB/trunk/lib/irb/context.rb
DietRB/trunk/spec/context_spec.rb
Modified: DietRB/trunk/lib/irb/context.rb
===================================================================
--- DietRB/trunk/lib/irb/context.rb 2010-10-08 11:01:20 UTC (rev 4698)
+++ DietRB/trunk/lib/irb/context.rb 2010-10-08 11:01:29 UTC (rev 4699)
@@ -48,6 +48,7 @@
puts formatter.result(result)
result
rescue Exception => e
+ store_exception(e)
puts formatter.exception(e)
end
@@ -114,6 +115,10 @@
def store_result(result)
@underscore_assigner.call(result)
end
+
+ def store_exception(exception)
+ $e = $EXCEPTION = exception
+ end
end
end
Modified: DietRB/trunk/spec/context_spec.rb
===================================================================
--- DietRB/trunk/spec/context_spec.rb 2010-10-08 11:01:20 UTC (rev 4698)
+++ DietRB/trunk/spec/context_spec.rb 2010-10-08 11:01:29 UTC (rev 4699)
@@ -112,6 +112,13 @@
}.should.not.raise
end
+ it "assigns the last raised exception to the global variable `$EXCEPTION' / `$e'" do
+ @context.evaluate("DoesNotExist")
+ $EXCEPTION.should.be.instance_of NameError
+ $EXCEPTION.message.should.include 'DoesNotExist'
+ $e.should == $EXCEPTION
+ end
+
it "prints the exception that occurs" do
@context.evaluate("DoesNotExist")
@context.printed.should.match /^NameError:.+DoesNotExist/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101008/8ba11272/attachment.html>
More information about the macruby-changes
mailing list