Package org.codehaus.groovy.syntax

# Class TokenException

java.lang.Object
java.lang.Throwable
java.lang.Exception
org.codehaus.groovy.GroovyException
org.codehaus.groovy.syntax.SyntaxException
org.codehaus.groovy.syntax.TokenException

All Implemented Interfaces:
  `Serializable`, `GroovyExceptionInterface`

Direct Known Subclasses:
  `ParserException`, `TokenMismatchException`

public class TokenException extends SyntaxException
Exception thrown when a token-related error is encountered during parsing. Extends `SyntaxException` to provide lexical-level error information using a `Token` as the error location reference.

See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TokenException(String message, Throwable cause, int line, int column)`
  Constructs a TokenException with explicit position and a cause.
  `TokenException(String message, Throwable cause, int line, int column, int endLine, int endColumn)`
  Constructs a TokenException with explicit position range and a cause.
  `TokenException(String message, Token token)`
  Constructs a TokenException from a token and error message.

- ## Method Summary

  ### Methods inherited from class org.codehaus.groovy.syntax.SyntaxException

  `getEndColumn, getEndLine, getLine, getMessage, getOriginalMessage, getSourceLocator, getStartColumn, getStartLine, setSourceLocator`

  ### Methods inherited from class org.codehaus.groovy.GroovyException

  `isFatal, setFatal`

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

  `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, 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

  - ### TokenException

    public TokenException(String message, Token token)
    Constructs a TokenException from a token and error message. The token's position information is used to determine error location.
    Parameters:
      `message` - the error message
      `token` - the `Token` where the error occurred (may be null)

  - ### TokenException

    public TokenException(String message, Throwable cause, int line, int column)
    Constructs a TokenException with explicit position and a cause.
    Parameters:
      `message` - the error message
      `cause` - the underlying `Throwable` that caused this exception
      `line` - the line number where the error occurs (1-based)
      `column` - the column number where the error occurs (1-based)

  - ### TokenException

    public TokenException(String message, Throwable cause, int line, int column, int endLine, int endColumn)
    Constructs a TokenException with explicit position range and a cause.
    Parameters:
      `message` - the error message
      `cause` - the underlying `Throwable` that caused this exception
      `line` - the starting line number (1-based)
      `column` - the starting column number (1-based)
      `endLine` - the ending line number (1-based)
      `endColumn` - the ending column number (1-based)