Package: org.codehaus.groovy.runtime.typehandling

## [Java] Class GroovyCastException

- org.codehaus.groovy.runtime.typehandling.GroovyCastException

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

- - ### Constructor Summary

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

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class ClassCastException` | `addSuppressed, equals, fillInStackTrace, getCause, getClass, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, hashCode, initCause, notify, notifyAll, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString, wait, wait, wait`

- - ### Constructor Detail

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

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

    - #### public GroovyCastException(String message)

      Constructs a GroovyCastException with a custom error message.

      Parameters:
        `message` - the error message