Package org.codehaus.groovy.runtime.typehandling

# Class GroovyCastException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
java.lang.ClassCastException
org.codehaus.groovy.runtime.typehandling.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:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GroovyCastException(Object objectToCast, Class classToCastTo)`
  Constructs a GroovyCastException with details of the failed cast.
  `GroovyCastException(Object objectToCast, Class classToCastTo, Exception cause)`
  Constructs a GroovyCastException with details of the failed cast and its cause.
  `GroovyCastException(String message)`
  Constructs a GroovyCastException with a custom error message.

- ## Method Summary

  ### Methods inherited from class java.lang.Throwable

  `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## 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