Class InvalidSyntaxException
java.lang.Object
java.lang.Throwable
java.lang.Exception
eu.svjatoslav.commons.string.tokenizer.InvalidSyntaxException
- All Implemented Interfaces:
Serializable
Exception thrown when token parsing encounters unexpected content.
This exception is thrown by the tokenizer when expectations fail, such as:
Tokenizer.expectAndConsumeNextStringToken(String)- when the next token doesn't match the expected valueTokenizer.expectAndConsumeNextTerminatorToken(Terminator)- when the next token was matched by a different terminatorTokenizer.peekExpectNoneOf(String...)- when the next token matches a forbidden value
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 Summary
ConstructorsConstructorDescriptionInvalidSyntaxException(String cause) Creates a new InvalidSyntaxException with a descriptive message. -
Method Summary
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
InvalidSyntaxException
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.
-