Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java::JavaLang::Throwable missing full_message method #5906

Closed
davishmcclurg opened this issue Oct 4, 2019 · 1 comment · Fixed by #5908
Closed

Java::JavaLang::Throwable missing full_message method #5906

davishmcclurg opened this issue Oct 4, 2019 · 1 comment · Fixed by #5908

Comments

@davishmcclurg
Copy link
Contributor

@davishmcclurg davishmcclurg commented Oct 4, 2019

I don't know if this is expected behavior, but I was surprised that Java::JavaLang::Throwable does not implement full_message:

irb(main):011:0> JRUBY_VERSION
=> "9.2.8.0"
irb(main):012:0> Java::JavaLang::Throwable.new('ugh').full_message
Traceback (most recent call last):
        6: from /Users/dharsha/.rbenv/versions/jruby-9.2.8.0/bin/irb:13:in `<main>'
        5: from org/jruby/RubyKernel.java:1193:in `catch'
        4: from org/jruby/RubyKernel.java:1193:in `catch'
        3: from org/jruby/RubyKernel.java:1425:in `loop'
        2: from org/jruby/RubyKernel.java:1061:in `eval'
        1: from (irb):12:in `evaluate'
NoMethodError (undefined method `full_message' for java.lang.Throwable: ugh:Java::JavaLang::Throwable)
Did you mean?  message
irb(main):013:0> StandardError.new('ugh').full_message
=> "(irb):12: ugh (StandardError)\n"
@davishmcclurg davishmcclurg changed the title Java::JavaLang::Throwable missing full_exception method Java::JavaLang::Throwable missing full_message method Oct 4, 2019
@kares

This comment has been minimized.

Copy link
Member

@kares kares commented Oct 6, 2019

throwable is the more general Java object here and Ruby exceptions are throwables :)
but yeah, the concern is valid as JRuby makes throwables Ruby Exception-like.

you could setup full_message as an alias to inspect, it would likely get merged ...
https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/javasupport/ext/JavaLang.java#L244 (the format would be slightly different but I think its a fine start)

davishmcclurg added a commit to davishmcclurg/jruby that referenced this issue Oct 8, 2019
Since Java throwables are treated similarly to regular Ruby exceptions,
I think it makes sense to implement `full_message` for easier logging
and debugging.

This moves the `RubyException` implementation to `TraceType` so that it
can be shared with `Throwable`. I had to change the `exception` argument
type in `printBacktraceMRI` in order to support the exception-like
object that `Throwable` provides.

Closes: jruby#5906
@headius headius closed this in #5908 Oct 8, 2019
@headius headius added this to the JRuby 9.2.9.0 milestone Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.