Class UnexpectedTokenException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- com.github.zafarkhaja.semver.ParseException
-
- com.github.zafarkhaja.semver.expr.UnexpectedTokenException
-
- All Implemented Interfaces:
java.io.Serializable
public class UnexpectedTokenException extends ParseException
Thrown when a token of unexpected types is encountered during the parsing.- Since:
- 0.7.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private Lexer.Token.Type[]
expected
The array of the expected token types.private Lexer.Token
unexpected
The unexpected token.
-
Constructor Summary
Constructors Constructor Description UnexpectedTokenException(Lexer.Token token, Lexer.Token.Type... expected)
Constructs aUnexpectedTokenException
instance with the unexpected token and the expected types.UnexpectedTokenException(UnexpectedElementException cause)
Constructs aUnexpectedTokenException
instance with the wrappedUnexpectedElementException
exception.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) Lexer.Token.Type[]
getExpectedTokenTypes()
Gets the expected token types.(package private) Lexer.Token
getUnexpectedToken()
Gets the unexpected token.java.lang.String
toString()
Returns the string representation of this exception containing the information about the unexpected token and, if available, about the expected types.
-
-
-
Field Detail
-
unexpected
private final Lexer.Token unexpected
The unexpected token.
-
expected
private final Lexer.Token.Type[] expected
The array of the expected token types.
-
-
Constructor Detail
-
UnexpectedTokenException
UnexpectedTokenException(UnexpectedElementException cause)
Constructs aUnexpectedTokenException
instance with the wrappedUnexpectedElementException
exception.- Parameters:
cause
- the wrapped exception
-
UnexpectedTokenException
UnexpectedTokenException(Lexer.Token token, Lexer.Token.Type... expected)
Constructs aUnexpectedTokenException
instance with the unexpected token and the expected types.- Parameters:
token
- the unexpected tokenexpected
- an array of the expected token types
-
-
Method Detail
-
getUnexpectedToken
Lexer.Token getUnexpectedToken()
Gets the unexpected token.- Returns:
- the unexpected token
-
getExpectedTokenTypes
Lexer.Token.Type[] getExpectedTokenTypes()
Gets the expected token types.- Returns:
- an array of expected token types
-
toString
public java.lang.String toString()
Returns the string representation of this exception containing the information about the unexpected token and, if available, about the expected types.- Overrides:
toString
in classParseException
- Returns:
- the string representation of this exception
-
-