From: David ‘Bombe’ Roden Date: Fri, 25 Oct 2013 05:20:11 +0000 (+0200) Subject: Throw a different exception if a Sone is too new. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=7718e043b740570a1b1002e58eb8793fb7ebbb07;p=Sone.git Throw a different exception if a Sone is too new. --- diff --git a/src/main/java/net/pterodactylus/sone/core/SoneParser.java b/src/main/java/net/pterodactylus/sone/core/SoneParser.java index a658ae1..98af5b6 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneParser.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneParser.java @@ -97,7 +97,7 @@ public class SoneParser { } if (protocolVersion.get() > MAX_PROTOCOL_VERSION) { logger.log(Level.WARNING, String.format("Unknown protocol version: %d! Not parsing Sone.", protocolVersion.get())); - throw new InvalidProtocolVersion(); + throw new SoneTooNew(); } } @@ -338,6 +338,10 @@ public class SoneParser { } + public static class SoneTooNew extends RuntimeException { + + } + public static class MalformedXml extends RuntimeException { } diff --git a/src/test/java/net/pterodactylus/sone/core/SoneParserTest.java b/src/test/java/net/pterodactylus/sone/core/SoneParserTest.java index e785a4d..03bce54 100644 --- a/src/test/java/net/pterodactylus/sone/core/SoneParserTest.java +++ b/src/test/java/net/pterodactylus/sone/core/SoneParserTest.java @@ -24,6 +24,7 @@ import net.pterodactylus.sone.core.SoneParser.InvalidXml; import net.pterodactylus.sone.core.SoneParser.MalformedDimension; import net.pterodactylus.sone.core.SoneParser.MalformedTime; import net.pterodactylus.sone.core.SoneParser.MalformedXml; +import net.pterodactylus.sone.core.SoneParser.SoneTooNew; import net.pterodactylus.sone.data.Client; import net.pterodactylus.sone.data.Image; import net.pterodactylus.sone.data.Post; @@ -76,7 +77,7 @@ public class SoneParserTest { soneParser.parseSone(database, originalSone, getXml("negative-protocol-version")); } - @Test(expected = InvalidProtocolVersion.class) + @Test(expected = SoneTooNew.class) public void verifyThatATooLargeProtocolVersionCausesAnError() { soneParser.parseSone(database, originalSone, getXml("too-large-protocol-version")); }