Package org.jruby.api
Class Error
java.lang.Object
org.jruby.api.Error
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ArgumentError
argumentError
(ThreadContext context, int got, int expected) Return an instance of ArgumentError for the given argument list length, min, and max.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.static ArgumentError
argumentError
(ThreadContext context, String message) Return an instance of ArgumentError with the given message.static TypeError
createTypeError
(ThreadContext context, String message) Create an instance of TypeError with the given message.static String
createTypeErrorMessage
(ThreadContext context, IRubyObject object, RubyModule expectedType) Create a properly formatted error message for a typical TypeError.static EOFError
eofError
(ThreadContext context, String message) static RaiseException
floatDomainError
(ThreadContext context, String message) static RaiseException
frozenError
(ThreadContext context, IRubyObject object, String message) Create a frozen error with a simple ASCII String.static RaiseException
indexError
(ThreadContext context, String message) Create an index error with a simple ASCII String.static ArgumentError
keywordError
(ThreadContext context, String error, RubyArray keys) static RaiseException
nameError
(ThreadContext context, String message, String name) Create a name error with a simple ASCII String and the failing name.static RaiseException
nameError
(ThreadContext context, String message, String name, Throwable throwable) Create a name error with a simple ASCII String and the failing name.static RaiseException
nameError
(ThreadContext context, String message, IRubyObject name) Create a name error with a simple ASCII String and the failing name.static NotImplementedError
notImplementedError
(ThreadContext context, String message) static RaiseException
rangeError
(ThreadContext context, String message) Create a range error with a simple ASCII String.static RaiseException
runtimeError
(ThreadContext context, String message) Create a runtime error with a simple ASCII String.static Exception
toRubyException
(ThreadContext context, IOException ioe) static TypeError
typeError
(ThreadContext context, String message) Create a TypeError with the given message.static TypeError
typeError
(ThreadContext context, String startOfMessage, IRubyObject object, String restOfMessage) Create a TypeError with the given message.static TypeError
typeError
(ThreadContext context, IRubyObject object, String expectedType) Create a TypeError with the given message.static TypeError
typeError
(ThreadContext context, IRubyObject object, RubyModule expectedType) Create a TypeError with the given message.static RaiseException
withException
(RaiseException error, Exception exception) Attach an exception to an error.Rstatic RaiseException
zeroDivisionError
(ThreadContext context) Create a TypeError with the given message.
-
Constructor Details
-
Error
public Error()
-
-
Method Details
-
argumentError
Return an instance of ArgumentError with the given message.- Parameters:
context
- the current thread contextmessage
- 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:
- the created exception
-
argumentError
Return an instance of ArgumentError for the given argument list length, min, and max.- Parameters:
context
- the current thread contextgot
- how many arguments we receivedexpected
- how many arguments we expect- Returns:
- the created exception
-
argumentError
Return an instance of ArgumentError for the given argument list length, min, and max.- Parameters:
context
- the current thread contextlength
- the length of the given argument arraymin
- the minimum length requiredmax
- the maximum length required- Returns:
- the created exception
-
floatDomainError
-
frozenError
Create a frozen error with a simple ASCII String.- Parameters:
context
- the current thread contextobject
- which is the frozen objectmessage
- to be displayed in the error- Returns:
- the error
-
indexError
Create an index error with a simple ASCII String.- Parameters:
context
- the current thread contextmessage
- to be displayed in the error- Returns:
- the error
-
nameError
Create a name error with a simple ASCII String and the failing name.- Parameters:
context
- the current thread contextmessage
- to be displayed in the errorname
- involved in the error- Returns:
- the error
-
nameError
Create a name error with a simple ASCII String and the failing name.- Parameters:
context
- the current thread contextmessage
- to be displayed in the errorname
- involved in the error- Returns:
- the error
-
nameError
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
- the current thread contextmessage
- to be displayed in the errorname
- involved in the errorthrowable
- the exception which caused this name error- Returns:
- the error
-
rangeError
Create a range error with a simple ASCII String.- Parameters:
context
- the current thread contextmessage
- to be displayed in the error- Returns:
- the error
-
runtimeError
Create a runtime error with a simple ASCII String.- Parameters:
context
- the current thread contextmessage
- to be displayed in the error- Returns:
- the error
-
typeError
Create a TypeError with the given message.- Parameters:
context
- the current thread contextobject
- which is the wrong typeexpectedType
- the expected type(s) that object should have been
-
typeError
public static TypeError typeError(ThreadContext context, String startOfMessage, IRubyObject object, String restOfMessage) Create a TypeError with the given message.- Parameters:
context
- the current thread contextstartOfMessage
- the start of the messageobject
- which is the wrong typerestOfMessage
- the rest of the message
-
typeError
public static TypeError typeError(ThreadContext context, IRubyObject object, RubyModule expectedType) Create a TypeError with the given message.- Parameters:
context
- the current thread contextobject
- which is the wrong typeexpectedType
- the expected type that object should have been
-
typeError
Create a TypeError with the given message.- Parameters:
context
- the current thread contextmessage
- 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
-
zeroDivisionError
Create a TypeError with the given message.- Parameters:
context
- the current thread context
-
createTypeError
Create an instance of TypeError with the given message.- Parameters:
context
- the current thread contextmessage
- 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:
- the created exception
-
createTypeErrorMessage
public static String createTypeErrorMessage(ThreadContext context, IRubyObject object, RubyModule expectedType) Create a properly formatted error message for a typical TypeError.- Parameters:
context
- the current thread contextobject
- which is the wrong typeexpectedType
- the expected type that object should have been- Returns:
- the created exception
-
withException
Attach an exception to an error.R- Parameters:
error
- the error to attach the exception toexception
- the exception to attach- Returns:
- the error with the exception attached
-
notImplementedError
-
keywordError
-
toRubyException
-
eofError
-