Skip to content

Made Exception#set_backtrace compliant with Ruby documentation#2067

Closed
pabloatplumbee wants to merge 3 commits intojruby:masterfrom
pabloatplumbee:master
Closed

Made Exception#set_backtrace compliant with Ruby documentation#2067
pabloatplumbee wants to merge 3 commits intojruby:masterfrom
pabloatplumbee:master

Conversation

@pabloatplumbee
Copy link
Contributor

This change fixes #1919, and makes jRuby complaint with Exception#set_backtrace documentation, which states that:

The backtrace must be an array of String objects or a single String in the format described in #backtrace.

This behaviour is confirmed in different MRI versions:

ruby-1.9.3-p545

1.9.3-p545 :001 > Exception.new.set_backtrace 'foo'
 => ["foo"] 
1.9.3-p545 :002 > 

ruby-2.0.0-p0

irb(main):001:0>  Exception.new.set_backtrace 'foo'
=> ["foo"]

ruby-2.1.1

2.1.1 :001 > Exception.new.set_backtrace 'foo'
 => ["foo"] 

But not in jruby:

jruby-1.7.11

jruby-1.7.11 :001 >  Exception.new.set_backtrace 'foo'
TypeError: backtrace must be Array of String
    from org/jruby/RubyException.java:95:in `set_backtrace'
    from (irb):1:in `evaluate'
    from org/jruby/RubyKernel.java:1121:in `eval'
    from org/jruby/RubyKernel.java:1521:in `loop'
    from org/jruby/RubyKernel.java:1284:in `catch'
    from org/jruby/RubyKernel.java:1284:in `catch'
    from /home/pablo/.rvm/rubies/jruby-1.7.11/bin/irb:13:in `(root)'

jruby-1.7.13

jruby-1.7.13 :001 >  Exception.new.set_backtrace 'foo'
TypeError: backtrace must be Array of String
    from org/jruby/RubyException.java:95:in `set_backtrace'
    from (irb):1:in `evaluate'
    from org/jruby/RubyKernel.java:1101:in `eval'
    from org/jruby/RubyKernel.java:1501:in `loop'
    from org/jruby/RubyKernel.java:1264:in `catch'
    from org/jruby/RubyKernel.java:1264:in `catch'
    from /home/pablo/.rvm/rubies/jruby-1.7.13/bin/irb:13:in `(root)'

@headius
Copy link
Member

headius commented Nov 2, 2014

Duplicated without merge commit by #2068.

@headius headius closed this Nov 2, 2014
@headius headius added this to the Invalid or Duplicate milestone Nov 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Call Exception#set_bactrace when raising exception

2 participants