Class GroovyCastException

All Implemented Interfaces:
Serializable

public class GroovyCastException extends ClassCastException
Exception thrown when a type cast or coercion fails.

This exception provides detailed information about the object that failed to cast, the target type, and any underlying cause. The error messages suggest alternative wrapper types when casting to primitive wrapper classes.

See Also:
  • Constructor Details

    • GroovyCastException

      public GroovyCastException(Object objectToCast, Class classToCastTo, Exception cause)
      Constructs a GroovyCastException with details of the failed cast and its cause.
      Parameters:
      objectToCast - the object that failed to cast
      classToCastTo - the target class
      cause - the underlying exception (message is included in the error)
    • GroovyCastException

      public GroovyCastException(Object objectToCast, Class classToCastTo)
      Constructs a GroovyCastException with details of the failed cast.
      Parameters:
      objectToCast - the object that failed to cast
      classToCastTo - the target class
    • GroovyCastException

      public GroovyCastException(String message)
      Constructs a GroovyCastException with a custom error message.
      Parameters:
      message - the error message