Package com.github.zafarkhaja.semver
Class UnexpectedCharacterException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.github.zafarkhaja.semver.ParseException
com.github.zafarkhaja.semver.UnexpectedCharacterException
- All Implemented Interfaces:
Serializable
Thrown when attempting to consume a character of unexpected types.
This exception is a wrapper exception extending
ParseException
.- Since:
- 0.8.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final VersionParser.CharType[]
The array of expected character types.private final int
The position of the unexpected character.private final Character
The unexpected character. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs aUnexpectedCharacterException
instance with the wrappedUnexpectedElementException
exception.UnexpectedCharacterException
(Character unexpected, int position, VersionParser.CharType... expected) Constructs aUnexpectedCharacterException
instance with the unexpected character, its position and the expected types. -
Method Summary
Modifier and TypeMethodDescription(package private) VersionParser.CharType[]
Gets the expected character types.(package private) int
Gets the position of the unexpected character.(package private) Character
Gets the unexpected character.toString()
Returns the string representation of this exception containing the information about the unexpected element and, if available, about the expected types.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Field Details
-
unexpected
The unexpected character. -
position
private final int positionThe position of the unexpected character. -
expected
The array of expected character types.
-
-
Constructor Details
-
UnexpectedCharacterException
UnexpectedCharacterException(UnexpectedElementException cause) Constructs aUnexpectedCharacterException
instance with the wrappedUnexpectedElementException
exception.- Parameters:
cause
- the wrapped exception
-
UnexpectedCharacterException
UnexpectedCharacterException(Character unexpected, int position, VersionParser.CharType... expected) Constructs aUnexpectedCharacterException
instance with the unexpected character, its position and the expected types.- Parameters:
unexpected
- the unexpected characterposition
- the position of the unexpected characterexpected
- an array of the expected character types
-
-
Method Details
-
getUnexpectedCharacter
Character getUnexpectedCharacter()Gets the unexpected character.- Returns:
- the unexpected character
-
getPosition
int getPosition()Gets the position of the unexpected character.- Returns:
- the position of the unexpected character
-
getExpectedCharTypes
VersionParser.CharType[] getExpectedCharTypes()Gets the expected character types.- Returns:
- an array of expected character types
-
toString
Returns the string representation of this exception containing the information about the unexpected element and, if available, about the expected types.- Overrides:
toString
in classParseException
- Returns:
- the string representation of this exception
-