Top Inners Fields Constructors Methods
org.jruby

public Class RubyException

extends RubyObject
Class Inheritance
Known Direct Subclasses
org.jruby.RubyFatal, org.jruby.RubyNoMemoryError, org.jruby.RubyScriptError, org.jruby.RubySecurityError, org.jruby.RubySignalException, org.jruby.RubyStandardError, org.jruby.RubySystemExit, org.jruby.RubySystemStackError, org.jruby.NativeException
Annotations
@JRubyClass
name:Exception
Imports
org.jruby.anno.JRubyClass, .JRubyMethod, org.jruby.api.Create, org.jruby.exceptions.Exception, .JumpException.FlowControlException, .RaiseException, org.jruby.java.proxies.ConcreteJavaProxy, org.jruby.runtime.*, org.jruby.runtime.backtrace.BacktraceData, .RubyStackTraceElement, .TraceType, org.jruby.runtime.builtin.IRubyObject, .Variable, org.jruby.runtime.component.VariableEntry, org.jruby.runtime.marshal.MarshalDumper, .MarshalLoader, org.jruby.util.CommonByteLists, .Sprintf, org.jruby.util.io.RubyInputStream, .RubyOutputStream, java.io.IOException, .PrintStream, java.util.List

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final RubyException.Backtrace
private IRubyObject
public static final ObjectAllocator
private static final ObjectMarshal<RubyException>
pack-priv IRubyObject
private RaiseException
public static final int
public static final int
public static final int
Inherited from org.jruby.RubyObject:
IVAR_INSPECTING_OBJECT_ALLOCATOROBJECT_ALLOCATORREIFYING_OBJECT_ALLOCATOR

Constructor Summary

AccessConstructor and Description
protected
RubyException(Ruby runtime, RubyClass rubyClass)

public
RubyException(Ruby runtime, RubyClass rubyClass, String message)

Method Summary

Modifier and TypeMethod and Description
private static RubyThread.Location
public IRubyObject
public IRubyObject
public void
public IRubyObject
private static IRubyObject
protected RaiseException
public void
public static RubyClass
public IRubyObject
public IRubyObject
public IRubyObject
public static IRubyObject
exception(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)

public RubyException
public IRubyObject
public IRubyObject
public IRubyObject
public RubyStackTraceElement[]
public Object
public IRubyObject

Returns:

error message if provided or nil
getMessage
()

public String
public List<Variable<Object>>
public List<String>
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
initialize(IRubyObject[] args, Block block)

public RubyString

Returns:

A RubyString containing the debug information.
inspect
(ThreadContext context)

Overrides org.jruby.RubyBasicObject.inspect.

Overrides default org.jruby.runtime.builtin.IRubyObject.inspect.

inspects an object and return a kind of debug information

private static boolean
private BacktraceData
public IRubyObject
public static RubyException
newException(Ruby runtime, RubyClass exceptionClass, String msg)

public static RubyException

Returns:

the new exception object
newException
(ThreadContext
the current thread context
context
,
RubyClass
the exception class
exceptionClass
,
RubyString
the message for the exception
message
)

Construct a new RubyException object from the given exception class and message.

public static RubyException

Returns:

the new exception object
newException
(ThreadContext
the current thread context
context
,
RubyClass
the exception class
exceptionClass
,
IRubyObject...
the arguments for the exception's constructor
args
)

Construct a new RubyException object from the given exception class and message.

public static IRubyObject
newException(ThreadContext context, RubyClass exceptionClass, IRubyObject message)
Deprecated

public static IRubyObject
public RubyBoolean
op_equal(ThreadContext context, IRubyObject other)

Overrides org.jruby.RubyBasicObject.op_equal.

Implements org.jruby.runtime.builtin.IRubyObject.op_equal.

rb_obj_equal Will by default use identity equality to compare objects.

public void
public void
printBacktrace(PrintStream
the PrintStream to which backtrace should be printed
errorStream
)

Print the Ruby exception's backtrace to the given PrintStream.

public void
printBacktrace(PrintStream
the PrintStream to which backtrace should be printed
errorStream
,
int skip)

Print the Ruby exception's backtrace to the given PrintStream.

public static IRubyObject

Returns:

set (or already generated) backtrace, null otherwise

Note

Internal API.

retrieveBacktrace
(RubyException exception)

Retrieve the current backtrace object for a given exception.

public IRubyObject
set_backtrace(IRubyObject obj)
Deprecated since 10.0.

public IRubyObject
public void
public void
public void
setMessage(IRubyObject
the message
message
)

Set the message for this NameError.

public IRubyObject
public static IRubyObject
public <T> T

Returns:

the converted result
toJava
(Class<T>
the target type to which this object should be converted
target
)

Overrides org.jruby.RubyBasicObject.toJava.

Implements org.jruby.runtime.builtin.IRubyObject.toJava.

Coerce this Ruby exception to the requested Java type, if possible.

public RaiseException
toThrowable()

Get a throwable suitable for throwing in Java.

Inherited from org.jruby.RubyObject:
attachToObjectSpacecallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitconvertToTypedigdig1dig2eqlInternalequalInternalequalsfinishObjectClassgetNativeClassIndexhashCodeinspectop_eqqputsspecificEvaltoRubyStringtoString

Field Detail

backtraceback to summary
private final RubyException.Backtrace backtrace
causeback to summary
private IRubyObject cause
EXCEPTION_ALLOCATORback to summary
public static final ObjectAllocator EXCEPTION_ALLOCATOR
EXCEPTION_MARSHALback to summary
private static final ObjectMarshal<RubyException> EXCEPTION_MARSHAL
messageback to summary
pack-priv IRubyObject message
throwableback to summary
private RaiseException throwable
TRACE_HEADback to summary
public static final int TRACE_HEAD
TRACE_MAXback to summary
public static final int TRACE_MAX
TRACE_TAILback to summary
public static final int TRACE_TAIL

Constructor Detail

RubyExceptionback to summary
protected RubyException(Ruby runtime, RubyClass rubyClass)
RubyExceptionback to summary
public RubyException(Ruby runtime, RubyClass rubyClass, String message)

Method Detail

asBacktraceLocationback to summary
private static RubyThread.Location asBacktraceLocation(IRubyObject object)
backtraceback to summary
public IRubyObject backtrace()
Annotations
@JRubyMethod
backtrace_locationsback to summary
public IRubyObject backtrace_locations(ThreadContext context)
Annotations
@JRubyMethod
omit:true
captureBacktraceback to summary
public void captureBacktrace(ThreadContext context)
causeback to summary
public IRubyObject cause(ThreadContext context)
Annotations
@JRubyMethod
name:cause
checkBacktraceback to summary
private static IRubyObject checkBacktrace(ThreadContext context, IRubyObject obj)
constructThrowableback to summary
protected RaiseException constructThrowable(String message)
copySpecialInstanceVariablesback to summary
public void copySpecialInstanceVariables(IRubyObject clone)

Overrides org.jruby.RubyBasicObject.copySpecialInstanceVariables.

Implements org.jruby.runtime.builtin.IRubyObject.copySpecialInstanceVariables.

Doc from org.jruby.RubyBasicObject.copySpecialInstanceVariables.

Lots of MRI objects keep their state in non-lookupable ivars (e:g. Range, Struct, etc). This method is responsible for dupping our java field equivalents

Annotations
@Override
createExceptionClassback to summary
public static RubyClass createExceptionClass(ThreadContext context, RubyClass Object)
detailed_messageback to summary
public IRubyObject detailed_message(ThreadContext context)
Annotations
@JRubyMethod
detailed_messageback to summary
public IRubyObject detailed_message(ThreadContext context, IRubyObject opts)
Annotations
@JRubyMethod
detailed_messageback to summary
public IRubyObject detailed_message(ThreadContext context, IRubyObject[] args)
Annotations
@JRubyMethod
optional:1
exceptionback to summary
public static IRubyObject exception(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
Annotations
@JRubyMethod
name:exception
rest:true
meta:true
exceptionback to summary
public RubyException exception(IRubyObject[] args)
Annotations
@JRubyMethod
optional:1
checkArity:false
full_messageback to summary
public IRubyObject full_message(ThreadContext context)
Annotations
@JRubyMethod
full_messageback to summary
public IRubyObject full_message(ThreadContext context, IRubyObject opts)
Annotations
@JRubyMethod
getBacktraceback to summary
public IRubyObject getBacktrace()
getBacktraceElementsback to summary
public RubyStackTraceElement[] getBacktraceElements()
getCauseback to summary
public Object getCause()
getMessageback to summary
public IRubyObject getMessage()
Returns:IRubyObject

error message if provided or nil

getMessageAsJavaStringback to summary
public String getMessageAsJavaString()
getVariableListback to summary
public List<Variable<Object>> getVariableList()

Overrides org.jruby.RubyBasicObject.getVariableList.

Implements org.jruby.runtime.builtin.IRubyObject.getVariableList.

Doc from org.jruby.RubyBasicObject.getVariableList.

Gets a list of all variables in this object.

Returns:List<Variable<Object>>

Doc from org.jruby.runtime.builtin.IRubyObject.getVariableList.

a list of all variables (ivar/internal)

Annotations
@Override
getVariableNameListback to summary
public List<String> getVariableNameList()

Overrides org.jruby.RubyBasicObject.getVariableNameList.

Implements org.jruby.runtime.builtin.IRubyObject.getVariableNameList.

Doc from org.jruby.RubyBasicObject.getVariableNameList.

Gets a name list of all variables in this object.

Returns:List<String>

Doc from org.jruby.runtime.builtin.IRubyObject.getVariableNameList.

a list of all variable names (ivar/cvar/constant/internal)

Annotations
@Override
initializeback to summary
public IRubyObject initialize(ThreadContext context)

Overrides org.jruby.RubyBasicObject.initialize.

Annotations
@JRubyMethod
visibility:PRIVATE
initializeback to summary
public IRubyObject initialize(ThreadContext context, IRubyObject arg0)
Annotations
@JRubyMethod
visibility:PRIVATE
initializeback to summary
public IRubyObject initialize(ThreadContext context, IRubyObject arg0, IRubyObject arg1)
Annotations
@JRubyMethod
visibility:PRIVATE
initializeback to summary
public IRubyObject initialize(IRubyObject[] args, Block block)
inspectback to summary
public RubyString inspect(ThreadContext context)

Overrides org.jruby.RubyBasicObject.inspect.

Overrides default org.jruby.runtime.builtin.IRubyObject.inspect.

inspects an object and return a kind of debug information

Returns:RubyString

A RubyString containing the debug information.

Annotations
@JRubyMethod
name:inspect
isArrayOfStringsback to summary
private static boolean isArrayOfStrings(IRubyObject backtrace)
locationArrayToBacktraceback to summary
private BacktraceData locationArrayToBacktrace(IRubyObject ary)
messageback to summary
public IRubyObject message(ThreadContext context)
Annotations
@JRubyMethod
name:message
newExceptionback to summary
public static RubyException newException(Ruby runtime, RubyClass exceptionClass, String msg)
newExceptionback to summary
public static RubyException newException(ThreadContext context, RubyClass exceptionClass, RubyString message)

Construct a new RubyException object from the given exception class and message.

Parameters
context:ThreadContext

the current thread context

exceptionClass:RubyClass

the exception class

message:RubyString

the message for the exception

Returns:RubyException

the new exception object

newExceptionback to summary
public static RubyException newException(ThreadContext context, RubyClass exceptionClass, IRubyObject... args)

Construct a new RubyException object from the given exception class and message.

Parameters
context:ThreadContext

the current thread context

exceptionClass:RubyClass

the exception class

args:IRubyObject[]

the arguments for the exception's constructor

Returns:RubyException

the new exception object

newExceptionback to summary
public static IRubyObject newException(ThreadContext context, RubyClass exceptionClass, IRubyObject message)

Deprecated

Annotations
@Deprecated
op_eqqback to summary
public static IRubyObject op_eqq(ThreadContext context, IRubyObject recv, IRubyObject other)
Annotations
@JRubyMethod
name:===
meta:true
op_equalback to summary
public RubyBoolean op_equal(ThreadContext context, IRubyObject other)

Overrides org.jruby.RubyBasicObject.op_equal.

Implements org.jruby.runtime.builtin.IRubyObject.op_equal.

Doc from org.jruby.RubyBasicObject.op_equal.

rb_obj_equal Will by default use identity equality to compare objects. This follows the Ruby semantics. The name of this method doesn't follow the convention because hierarchy problems

Annotations
@Override
@JRubyMethod
name:==
prepareIntegratedBacktraceback to summary
public void prepareIntegratedBacktrace(ThreadContext context, StackTraceElement[] javaTrace)

Deprecated

Annotations
@Deprecated
printBacktraceback to summary
public void printBacktrace(PrintStream errorStream)

Print the Ruby exception's backtrace to the given PrintStream.

Parameters
errorStream:PrintStream

the PrintStream to which backtrace should be printed

printBacktraceback to summary
public void printBacktrace(PrintStream errorStream, int skip)

Print the Ruby exception's backtrace to the given PrintStream. This version accepts a number of lines to skip and is primarily used internally for exception printing where the first line is treated specially.

Parameters
errorStream:PrintStream

the PrintStream to which backtrace should be printed

retrieveBacktraceback to summary
public static IRubyObject retrieveBacktrace(RubyException exception)

Retrieve the current backtrace object for a given exception.

Returns:IRubyObject

set (or already generated) backtrace, null otherwise

Note

Internal API.

set_backtraceback to summary
public IRubyObject set_backtrace(IRubyObject obj)

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
set_backtraceback to summary
public IRubyObject set_backtrace(ThreadContext context, IRubyObject obj)
Annotations
@JRubyMethod
setBacktraceback to summary
public void setBacktrace(ThreadContext context, IRubyObject obj)
setCauseback to summary
public void setCause(IRubyObject cause)
setMessageback to summary
public void setMessage(IRubyObject message)

Set the message for this NameError.

Parameters
message:IRubyObject

the message

to_sback to summary
public IRubyObject to_s(ThreadContext context)

Overrides org.jruby.RubyBasicObject.to_s.

Annotations
@JRubyMethod
name:to_s
to_tty_pback to summary
public static IRubyObject to_tty_p(ThreadContext context, IRubyObject recv)
Annotations
@JRubyMethod
name:to_tty?
meta:true
toJavaback to summary
public <T> T toJava(Class<T> target)

Overrides org.jruby.RubyBasicObject.toJava.

Implements org.jruby.runtime.builtin.IRubyObject.toJava.

Coerce this Ruby exception to the requested Java type, if possible. If the requested type is a supertype of RaiseException, the attached throwable will be returned. Otherwise, it will fall back on RubyBasicObject toJava logic.

Parameters
<T>

Doc from org.jruby.runtime.builtin.IRubyObject.toJava. type

target:Class<T>

the target type to which this object should be converted

Returns:T

the converted result

Annotations
@Override
toThrowableback to summary
public RaiseException toThrowable()

Get a throwable suitable for throwing in Java. The throwable here will be constructed lazily by calling constructThrowable and then cached for future calls. All throwables returned by Ruby exception objects will descend from RaiseException and follow the Throwable hierarchy below Exception

org.jruby back to summary

private Class RubyException.Backtrace

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private BacktraceData
private IRubyObject
private IRubyObject

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
public IRubyObject

Returns:

the generated Ruby backtrace
generateBacktrace
(Ruby runtime)

Generate a new backtrace (or returns nil if no backtrace data exists).

public IRubyObject

Returns:

the array of backtrace locations
generateBacktraceLocations
(ThreadContext
the current thread context
context
)

Generate an array of backtrace location objects for this backtrace.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

backtraceDataback to summary
private BacktraceData backtraceData
backtraceLocationsback to summary
private IRubyObject backtraceLocations
backtraceObjectback to summary
private IRubyObject backtraceObject

Constructor Detail

Backtraceback to summary
private Backtrace()

Method Detail

copyback to summary
public void copy(RubyException.Backtrace clone)
generateBacktraceback to summary
public IRubyObject generateBacktrace(Ruby runtime)

Generate a new backtrace (or returns nil if no backtrace data exists).

Returns:IRubyObject

the generated Ruby backtrace

generateBacktraceLocationsback to summary
public IRubyObject generateBacktraceLocations(ThreadContext context)

Generate an array of backtrace location objects for this backtrace.

Parameters
context:ThreadContext

the current thread context

Returns:IRubyObject

the array of backtrace locations