Package org.jruby.api

Class Error

java.lang.Object
org.jruby.api.Error

public class Error extends Object
  • Constructor Details

    • Error

      public Error()
  • Method Details

    • argumentError

      public static ArgumentError argumentError(ThreadContext context, String message)
      Return an instance of ArgumentError with the given message.
      Parameters:
      context - the current thread context
      message - 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

      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 - the current thread context
      got - how many arguments we received
      expected - how many arguments we expect
      Returns:
      the created exception
    • argumentError

      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 - the current thread context
      length - the length of the given argument array
      min - the minimum length required
      max - the maximum length required
      Returns:
      the created exception
    • floatDomainError

      public static RaiseException floatDomainError(ThreadContext context, String message)
    • frozenError

      public static RaiseException frozenError(ThreadContext context, IRubyObject object, String message)
      Create a frozen error with a simple ASCII String.
      Parameters:
      context - the current thread context
      object - which is the frozen object
      message - to be displayed in the error
      Returns:
      the error
    • indexError

      public static RaiseException indexError(ThreadContext context, String message)
      Create an index error with a simple ASCII String.
      Parameters:
      context - the current thread context
      message - to be displayed in the error
      Returns:
      the error
    • nameError

      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 - the current thread context
      message - to be displayed in the error
      name - involved in the error
      Returns:
      the error
    • nameError

      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 - the current thread context
      message - to be displayed in the error
      name - 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 context
      message - to be displayed in the error
      name - involved in the error
      throwable - the exception which caused this name error
      Returns:
      the error
    • rangeError

      public static RaiseException rangeError(ThreadContext context, String message)
      Create a range error with a simple ASCII String.
      Parameters:
      context - the current thread context
      message - to be displayed in the error
      Returns:
      the error
    • runtimeError

      public static RaiseException runtimeError(ThreadContext context, String message)
      Create a runtime error with a simple ASCII String.
      Parameters:
      context - the current thread context
      message - to be displayed in the error
      Returns:
      the error
    • typeError

      public static TypeError typeError(ThreadContext context, IRubyObject object, String expectedType)
      Create a TypeError with the given message.
      Parameters:
      context - the current thread context
      object - which is the wrong type
      expectedType - 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 context
      startOfMessage - the start of the message
      object - which is the wrong type
      restOfMessage - 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 context
      object - which is the wrong type
      expectedType - the expected type that object should have been
    • typeError

      public static TypeError typeError(ThreadContext context, String message)
      Create a TypeError with the given message.
      Parameters:
      context - the current thread context
      message - 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

      public static RaiseException zeroDivisionError(ThreadContext context)
      Create a TypeError with the given message.
      Parameters:
      context - the current thread context
    • createTypeError

      public static TypeError createTypeError(ThreadContext context, String message)
      Create an instance of TypeError with the given message.
      Parameters:
      context - the current thread context
      message - 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 context
      object - which is the wrong type
      expectedType - the expected type that object should have been
      Returns:
      the created exception
    • withException

      public static RaiseException withException(RaiseException error, Exception exception)
      Attach an exception to an error.R
      Parameters:
      error - the error to attach the exception to
      exception - the exception to attach
      Returns:
      the error with the exception attached
    • notImplementedError

      public static NotImplementedError notImplementedError(ThreadContext context, String message)
    • keywordError

      public static ArgumentError keywordError(ThreadContext context, String error, RubyArray keys)
    • toRubyException

      public static Exception toRubyException(ThreadContext context, IOException ioe)
    • eofError

      public static EOFError eofError(ThreadContext context, String message)