Class: Java::java::lang::Throwable

Inherits:
Object
  • Object
show all
Defined in:
core/src/main/ruby/jruby/java/java_ext/java.lang.rb

Overview

Java's java.lang.Throwable (exception/error) classes resemble Ruby's `Exception`.

See Also:

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (true, false) ===(ex)

Adds case compare against `NativeException` wrapped throwables.

Examples:

begin
  java.lang.Integer.parseInt('gg', 16)
rescue NativeException => ex
  expect( java.lang.NumberFormatException === ex ).to be true
end

Returns:

  • (true, false)


136
137
138
# File 'core/src/main/ruby/jruby/java/java_ext/java.lang.rb', line 136

def self.===(ex)
  # stub implemented in org.jruby.javasupport.ext.JavaLang.java
end

Instance Method Details

- (Array) backtrace

Returns the mapped stack-trace

Returns:

  • (Array)

    the mapped stack-trace



102
103
104
105
# File 'core/src/main/ruby/jruby/java/java_ext/java.lang.rb', line 102

def backtrace
  # stub implemented in org.jruby.javasupport.ext.JavaLang.java
  # stack_trace.map(&:to_s)
end

- (Object) inspect



124
125
126
# File 'core/src/main/ruby/jruby/java/java_ext/java.lang.rb', line 124

def inspect
  # to_string
end

- (String) message

Note:

getMessage still returns nil, when no message was given for the Java exception!

Always a non-nil to follow Ruby's Exception#message conventions.

Returns:

  • (String)


115
116
117
118
# File 'core/src/main/ruby/jruby/java/java_ext/java.lang.rb', line 115

def message
  # stub implemented in org.jruby.javasupport.ext.JavaLang.java
  # getLocalizedMessage || ''
end

- (Object) set_backtrace(trace)

Note:

Noop as Java exceptions can not change their stack-trace.



108
109
110
# File 'core/src/main/ruby/jruby/java/java_ext/java.lang.rb', line 108

def set_backtrace(trace)
  # stub implemented in org.jruby.javasupport.ext.JavaLang.java
end

- (Object) to_s



120
121
122
# File 'core/src/main/ruby/jruby/java/java_ext/java.lang.rb', line 120

def to_s
  # message
end