[jsemver] 69/95: Remove GrammarException in favor of ParseException
Alexandre Viau
reazem-guest at moszumanska.debian.org
Mon Feb 16 14:58:31 UTC 2015
This is an automated email from the git hooks/post-receive script.
reazem-guest pushed a commit to branch master
in repository jsemver.
commit 84b74fa602b7fa1d048b6ce075552c02ef4ae7a2
Author: Zafar Khaja <zafarkhaja at gmail.com>
Date: Tue Jan 21 14:36:48 2014 +0400
Remove GrammarException in favor of ParseException
---
.../github/zafarkhaja/semver/GrammarException.java | 43 ----------------------
.../github/zafarkhaja/semver/VersionParser.java | 36 +++++++++---------
.../zafarkhaja/semver/VersionParserTest.java | 6 +--
3 files changed, 21 insertions(+), 64 deletions(-)
diff --git a/src/main/java/com/github/zafarkhaja/semver/GrammarException.java b/src/main/java/com/github/zafarkhaja/semver/GrammarException.java
deleted file mode 100644
index e63adf9..0000000
--- a/src/main/java/com/github/zafarkhaja/semver/GrammarException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * The MIT License
- *
- * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.github.zafarkhaja.semver;
-
-/**
- * Thrown when an error occurs during the parsing specified
- * by the SemVer or the formal grammar of the parsed string.
- *
- * @author Zafar Khaja <zafarkhaja at gmail.com>
- * @since 0.7.0
- */
-public class GrammarException extends ParseException {
-
- /**
- * Constructs a {@code GrammarException} instance with an error message.
- *
- * @param message the error message
- */
- GrammarException(String message) {
- super(message);
- }
-}
diff --git a/src/main/java/com/github/zafarkhaja/semver/VersionParser.java b/src/main/java/com/github/zafarkhaja/semver/VersionParser.java
index db7ad6e..7f14bfd 100644
--- a/src/main/java/com/github/zafarkhaja/semver/VersionParser.java
+++ b/src/main/java/com/github/zafarkhaja/semver/VersionParser.java
@@ -138,8 +138,8 @@ class VersionParser implements Parser<Version> {
*
* @param input the input string to parse
* @return a valid version object
- * @throws GrammarException when there is an error defined in
- * the SemVer or the formal grammar
+ * @throws ParseException when there is an error defined in
+ * the SemVer or the formal grammar
* @throws UnexpectedElementException when encounters an unexpected character type
*/
@Override
@@ -152,8 +152,8 @@ class VersionParser implements Parser<Version> {
*
* @param version the version string to parse
* @return a valid version object
- * @throws GrammarException when there is an error defined in
- * the SemVer or the formal grammar
+ * @throws ParseException when there is an error defined in
+ * the SemVer or the formal grammar
* @throws UnexpectedElementException when encounters an unexpected character type
*/
static Version parseValidSemVer(String version) {
@@ -166,8 +166,8 @@ class VersionParser implements Parser<Version> {
*
* @param versionCore the version core string to parse
* @return a valid normal version object
- * @throws GrammarException when there is an error defined in
- * the SemVer or the formal grammar
+ * @throws ParseException when there is an error defined in
+ * the SemVer or the formal grammar
* @throws UnexpectedElementException when encounters an unexpected character type
*/
static NormalVersion parseVersionCore(String versionCore) {
@@ -180,8 +180,8 @@ class VersionParser implements Parser<Version> {
*
* @param preRelease the pre-release version string to parse
* @return a valid pre-release version object
- * @throws GrammarException when there is an error defined in
- * the SemVer or the formal grammar
+ * @throws ParseException when there is an error defined in
+ * the SemVer or the formal grammar
*/
static MetadataVersion parsePreRelease(String preRelease) {
if (preRelease == null) {
@@ -196,8 +196,8 @@ class VersionParser implements Parser<Version> {
*
* @param build the build metadata string to parse
* @return a valid build metadata object
- * @throws GrammarException when there is an error defined in
- * the SemVer or the formal grammar
+ * @throws ParseException when there is an error defined in
+ * the SemVer or the formal grammar
*/
static MetadataVersion parseBuild(String build) {
if (build == null) {
@@ -272,7 +272,7 @@ class VersionParser implements Parser<Version> {
* </pre>
*
* @return a valid pre-release version object
- * @throws GrammarException if the pre-release version has empty identifier(s)
+ * @throws ParseException if the pre-release version has empty identifier(s)
*/
private MetadataVersion parsePreRelease() {
CharType end = closestEndpoint(PLUS, EOL);
@@ -311,7 +311,7 @@ class VersionParser implements Parser<Version> {
* </pre>
*
* @return a valid build metadata object
- * @throws GrammarException if the build metadata has empty identifier(s)
+ * @throws ParseException if the build metadata has empty identifier(s)
*/
private MetadataVersion parseBuild() {
CharType end = EOL;
@@ -346,7 +346,7 @@ class VersionParser implements Parser<Version> {
* </pre>
*
* @return a string representing the numeric identifier
- * @throws GrammarException if the numeric identifier has leading zero(es)
+ * @throws ParseException if the numeric identifier has leading zero(es)
*/
private String numericIdentifier() {
checkForLeadingZeroes();
@@ -414,13 +414,13 @@ class VersionParser implements Parser<Version> {
/**
* Checks for leading zeroes in the numeric identifiers.
*
- * @throws GrammarException if a numeric identifier has leading zero(es)
+ * @throws ParseException if a numeric identifier has leading zero(es)
*/
private void checkForLeadingZeroes() {
Character la1 = chars.lookahead(1);
Character la2 = chars.lookahead(2);
if (la1 == '0' && DIGIT.isMatchedBy(la2)) {
- throw new GrammarException(
+ throw new ParseException(
"Numeric identifier MUST NOT contain leading zeroes"
);
}
@@ -429,12 +429,12 @@ class VersionParser implements Parser<Version> {
/**
* Checks for empty identifiers in the pre-release version or build metadata.
*
- * @throws GrammarException if the pre-release version or build
- * metadata have empty identifier(s)
+ * @throws ParseException if the pre-release version or build
+ * metadata have empty identifier(s)
*/
private void checkForEmptyIdentifier() {
if (DOT.isMatchedBy(chars.lookahead(1))) {
- throw new GrammarException("Identifiers MUST NOT be empty");
+ throw new ParseException("Identifiers MUST NOT be empty");
}
}
}
diff --git a/src/test/java/com/github/zafarkhaja/semver/VersionParserTest.java b/src/test/java/com/github/zafarkhaja/semver/VersionParserTest.java
index 7bf40ed..a2cfc39 100644
--- a/src/test/java/com/github/zafarkhaja/semver/VersionParserTest.java
+++ b/src/test/java/com/github/zafarkhaja/semver/VersionParserTest.java
@@ -42,7 +42,7 @@ public class VersionParserTest {
public void shouldRaiseErrorIfNumericIdentifierHasLeadingZeroes() {
try {
VersionParser.parseVersionCore("01.1.0");
- } catch (GrammarException e) {
+ } catch (ParseException e) {
return;
}
fail("Numeric identifier MUST NOT contain leading zeroes");
@@ -74,7 +74,7 @@ public class VersionParserTest {
public void shouldRaiseErrorForEmptyPreReleaseIdentifier() {
try {
VersionParser.parsePreRelease("beta-1..1");
- } catch (GrammarException e) {
+ } catch (ParseException e) {
return;
}
fail("Identifiers MUST NOT be empty");
@@ -105,7 +105,7 @@ public class VersionParserTest {
public void shouldRaiseErrorForEmptyBuildIdentifier() {
try {
VersionParser.parseBuild(".build.01");
- } catch (GrammarException e) {
+ } catch (ParseException e) {
return;
}
fail("Identifiers MUST NOT be empty");
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jsemver.git
More information about the pkg-java-commits
mailing list