From 7718e043b740570a1b1002e58eb8793fb7ebbb07 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 25 Oct 2013 07:20:11 +0200 Subject: [PATCH] Throw a different exception if a Sone is too new. --- src/main/java/net/pterodactylus/sone/core/SoneParser.java | 6 +++++- src/test/java/net/pterodactylus/sone/core/SoneParserTest.java | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) 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")); } -- 2.7.4