Class InvalidSyntaxException

java.lang.Object
java.lang.Throwable
java.lang.Exception
eu.svjatoslav.commons.string.tokenizer.InvalidSyntaxException
All Implemented Interfaces:
Serializable

public class InvalidSyntaxException extends Exception
Exception thrown when token parsing encounters unexpected content.

This exception is thrown by the tokenizer when expectations fail, such as:

Example handling:


 try {
     tokenizer.expectAndConsumeNextStringToken("if");
     // Parse if statement...
 } catch (InvalidSyntaxException e) {
     System.err.println("Syntax error: " + e.getMessage());
     // Error recovery or abort
 }
 

The exception message describes what was expected and what was actually encountered, useful for error reporting to users.

See Also:
  • Constructor Details

    • InvalidSyntaxException

      public InvalidSyntaxException(String cause)
      Creates a new InvalidSyntaxException with a descriptive message.

      The message should describe what was expected and what was found, to help users understand the syntax error.

      Parameters:
      cause - a description of the syntax error. Must not be null.