Package: org.codehaus.groovy.syntax

## [Java] Class TokenMismatchException

- org.codehaus.groovy.syntax.TokenMismatchException

-     public class TokenMismatchException
      extends TokenException

  Exception thrown when a parser encounters a token of an unexpected type. Contains information about both the unexpected token found and the expected token type. Extends TokenException to inherit token-based error reporting.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `TokenMismatchException(Token token, int expectedType)` Constructs a TokenMismatchException.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public int` | `getExpectedType()` Returns the token type that was expected.
    `` | `public Token` | `getUnexpectedToken()` Returns the unexpected token that triggered this exception.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class SyntaxException` | `getEndColumn, getEndLine, getLine, getMessage, getOriginalMessage, getSourceLocator, getStartColumn, getStartLine, setSourceLocator`
    `class GroovyException` | `isFatal, setFatal`

- - ### Constructor Detail

    - #### public TokenMismatchException(Token token, int expectedType)

      Constructs a TokenMismatchException.

      Parameters:
        `token` - the unexpected Token that was encountered
        `expectedType` - the expected token type from Types

  - ### Method Detail

    - #### public int getExpectedType()

      Returns the token type that was expected.

      Returns:
        the expected token type from Types

    - #### public Token getUnexpectedToken()

      Returns the unexpected token that triggered this exception.

      Returns:
        the unexpected Token