Top Constructors Methods
org.jruby.api

public Class Error

extends Object
Class Inheritance
Imports
org.jruby.Ruby, .RubyArray, .RubyFrozenError, .RubyModule, org.jruby.exceptions.ArgumentError, .EOFError, .IOError, .NotImplementedError, .RaiseException, .TypeError, org.jruby.runtime.Helpers, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, java.io.IOException

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static ArgumentError

Returns:

the created exception
argumentError
(ThreadContext
the current thread context
context
,
String
to be the message of the exception. Note that this message should be properly formatted using RubyStringBuilder.str() or you absolutely know it is clean ASCII-7BIT
message
)

Return an instance of ArgumentError with the given message.

public static ArgumentError

Returns:

the created exception
argumentError
(ThreadContext
the current thread context
context
,
int
how many arguments we received
got
,
int
how many arguments we expect
expected
)

Return an instance of ArgumentError for the given argument list length, min, and max.

public static ArgumentError

Returns:

the created exception
argumentError
(ThreadContext
the current thread context
context
,
int
the length of the given argument array
length
,
int
the minimum length required
min
,
int
the maximum length required
max
)

Return an instance of ArgumentError for the given argument list length, min, and max.

public static TypeError

Returns:

the created exception
createTypeError
(ThreadContext
the current thread context
context
,
String
to be the message of the exception. Note that this message should be properly formatted using RubyStringBuilder.str() or you absolutely know it is clean ASCII-7BIT
message
)

Create an instance of TypeError with the given message.

public static String

Returns:

the created exception
createTypeErrorMessage
(ThreadContext
the current thread context
context
,
IRubyObject
which is the wrong type
object
,
RubyModule
the expected type that object should have been
expectedType
)

Create a properly formatted error message for a typical TypeError.

public static EOFError
eofError(ThreadContext context, String message)

public static RaiseException
public static RaiseException

Returns:

the error
frozenError
(ThreadContext
the current thread context
context
,
IRubyObject
which is the frozen object
object
,
String
to be displayed in the error
message
)

Create a frozen error with a simple ASCII String.

public static RaiseException

Returns:

the error
indexError
(ThreadContext
the current thread context
context
,
String
to be displayed in the error
message
)

Create an index error with a simple ASCII String.

public static ArgumentError
keywordError(ThreadContext context, String error, RubyArray<T extends IRubyObject> keys)

public static RaiseException

Returns:

the error
nameError
(ThreadContext
the current thread context
context
,
String
to be displayed in the error
message
,
String
involved in the error
name
)

Create a name error with a simple ASCII String and the failing name.

public static RaiseException

Returns:

the error
nameError
(ThreadContext
the current thread context
context
,
String
to be displayed in the error
message
,
IRubyObject
involved in the error
name
)

Create a name error with a simple ASCII String and the failing name.

public static RaiseException

Returns:

the error
nameError
(ThreadContext
the current thread context
context
,
String
to be displayed in the error
message
,
String
involved in the error
name
,
Throwable
the exception which caused this name error
throwable
)

Create a name error with a simple ASCII String and the failing name.

public static NotImplementedError
public static RaiseException

Returns:

the error
rangeError
(ThreadContext
the current thread context
context
,
String
to be displayed in the error
message
)

Create a range error with a simple ASCII String.

public static RaiseException

Returns:

the error
runtimeError
(ThreadContext
the current thread context
context
,
String
to be displayed in the error
message
)

Create a runtime error with a simple ASCII String.

public static Exception
public static TypeError
typeError(ThreadContext
the current thread context
context
,
IRubyObject
which is the wrong type
object
,
String
the expected type(s) that object should have been
expectedType
)

Create a TypeError with the given message.

public static TypeError
typeError(ThreadContext
the current thread context
context
,
String
the start of the message
startOfMessage
,
IRubyObject
which is the wrong type
object
,
String
the rest of the message
restOfMessage
)

Create a TypeError with the given message.

public static TypeError
typeError(ThreadContext
the current thread context
context
,
IRubyObject
which is the wrong type
object
,
RubyModule
the expected type that object should have been
expectedType
)

Create a TypeError with the given message.

public static TypeError
typeError(ThreadContext
the current thread context
context
,
String
to be the message of the exception. Note that this message should be properly formatted using RubyStringBuilder.str() or you absolutely know it is clean ASCII-7BIT
message
)

Create a TypeError with the given message.

private static IRubyObject
typeFor(Ruby runtime, IRubyObject object)

public static RaiseException

Returns:

the error with the exception attached
withException
(RaiseException
the error to attach the exception to
error
,
Exception
the exception to attach
exception
)

Attach an exception to an error.R

public static RaiseException
zeroDivisionError(ThreadContext
the current thread context
context
)

Create a TypeError with the given message.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Errorback to summary
public Error()

Method Detail

argumentErrorback to summary
public static ArgumentError argumentError(ThreadContext context, String message)

Return an instance of ArgumentError with the given message.

Parameters
context:ThreadContext

the current thread context

message:String

to be the message of the exception. Note that this message should be properly formatted using RubyStringBuilder.str() or you absolutely know it is clean ASCII-7BIT

Returns:ArgumentError

the created exception

argumentErrorback to summary
public static ArgumentError argumentError(ThreadContext context, int got, int expected)

Return an instance of ArgumentError for the given argument list length, min, and max.

Parameters
context:ThreadContext

the current thread context

got:int

how many arguments we received

expected:int

how many arguments we expect

Returns:ArgumentError

the created exception

argumentErrorback to summary
public static ArgumentError argumentError(ThreadContext context, int length, int min, int max)

Return an instance of ArgumentError for the given argument list length, min, and max.

Parameters
context:ThreadContext

the current thread context

length:int

the length of the given argument array

min:int

the minimum length required

max:int

the maximum length required

Returns:ArgumentError

the created exception

createTypeErrorback to summary
public static TypeError createTypeError(ThreadContext context, String message)

Create an instance of TypeError with the given message.

Parameters
context:ThreadContext

the current thread context

message:String

to be the message of the exception. Note that this message should be properly formatted using RubyStringBuilder.str() or you absolutely know it is clean ASCII-7BIT

Returns:TypeError

the created exception

createTypeErrorMessageback to summary
public static String createTypeErrorMessage(ThreadContext context, IRubyObject object, RubyModule expectedType)

Create a properly formatted error message for a typical TypeError.

Parameters
context:ThreadContext

the current thread context

object:IRubyObject

which is the wrong type

expectedType:RubyModule

the expected type that object should have been

Returns:String

the created exception

eofErrorback to summary
public static EOFError eofError(ThreadContext context, String message)
floatDomainErrorback to summary
public static RaiseException floatDomainError(ThreadContext context, String message)
frozenErrorback to summary
public static RaiseException frozenError(ThreadContext context, IRubyObject object, String message)

Create a frozen error with a simple ASCII String.

Parameters
context:ThreadContext

the current thread context

object:IRubyObject

which is the frozen object

message:String

to be displayed in the error

Returns:RaiseException

the error

indexErrorback to summary
public static RaiseException indexError(ThreadContext context, String message)

Create an index error with a simple ASCII String.

Parameters
context:ThreadContext

the current thread context

message:String

to be displayed in the error

Returns:RaiseException

the error

keywordErrorback to summary
public static ArgumentError keywordError(ThreadContext context, String error, RubyArray<T extends IRubyObject> keys)
nameErrorback to summary
public static RaiseException nameError(ThreadContext context, String message, String name)

Create a name error with a simple ASCII String and the failing name.

Parameters
context:ThreadContext

the current thread context

message:String

to be displayed in the error

name:String

involved in the error

Returns:RaiseException

the error

nameErrorback to summary
public static RaiseException nameError(ThreadContext context, String message, IRubyObject name)

Create a name error with a simple ASCII String and the failing name.

Parameters
context:ThreadContext

the current thread context

message:String

to be displayed in the error

name:IRubyObject

involved in the error

Returns:RaiseException

the error

nameErrorback to summary
public static RaiseException nameError(ThreadContext context, String message, String name, Throwable throwable)

Create a name error with a simple ASCII String and the failing name.

Parameters
context:ThreadContext

the current thread context

message:String

to be displayed in the error

name:String

involved in the error

throwable:Throwable

the exception which caused this name error

Returns:RaiseException

the error

notImplementedErrorback to summary
public static NotImplementedError notImplementedError(ThreadContext context, String message)
rangeErrorback to summary
public static RaiseException rangeError(ThreadContext context, String message)

Create a range error with a simple ASCII String.

Parameters
context:ThreadContext

the current thread context

message:String

to be displayed in the error

Returns:RaiseException

the error

runtimeErrorback to summary
public static RaiseException runtimeError(ThreadContext context, String message)

Create a runtime error with a simple ASCII String.

Parameters
context:ThreadContext

the current thread context

message:String

to be displayed in the error

Returns:RaiseException

the error

toRubyExceptionback to summary
public static Exception toRubyException(ThreadContext context, IOException ioe)
typeErrorback to summary
public static TypeError typeError(ThreadContext context, IRubyObject object, String expectedType)

Create a TypeError with the given message.

Parameters
context:ThreadContext

the current thread context

object:IRubyObject

which is the wrong type

expectedType:String

the expected type(s) that object should have been

typeErrorback to summary
public static TypeError typeError(ThreadContext context, String startOfMessage, IRubyObject object, String restOfMessage)

Create a TypeError with the given message.

Parameters
context:ThreadContext

the current thread context

startOfMessage:String

the start of the message

object:IRubyObject

which is the wrong type

restOfMessage:String

the rest of the message

typeErrorback to summary
public static TypeError typeError(ThreadContext context, IRubyObject object, RubyModule expectedType)

Create a TypeError with the given message.

Parameters
context:ThreadContext

the current thread context

object:IRubyObject

which is the wrong type

expectedType:RubyModule

the expected type that object should have been

typeErrorback to summary
public static TypeError typeError(ThreadContext context, String message)

Create a TypeError with the given message.

Parameters
context:ThreadContext

the current thread context

message:String

to be the message of the exception. Note that this message should be properly formatted using RubyStringBuilder.str() or you absolutely know it is clean ASCII-7BIT

typeForback to summary
private static IRubyObject typeFor(Ruby runtime, IRubyObject object)
withExceptionback to summary
public static RaiseException withException(RaiseException error, Exception exception)

Attach an exception to an error.R

Parameters
error:RaiseException

the error to attach the exception to

exception:Exception

the exception to attach

Returns:RaiseException

the error with the exception attached

zeroDivisionErrorback to summary
public static RaiseException zeroDivisionError(ThreadContext context)

Create a TypeError with the given message.

Parameters
context:ThreadContext

the current thread context