Verify that an invalid parent album causes an error.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / SoneParser.java
index 2e23257..512da1b 100644 (file)
@@ -258,14 +258,14 @@ public class SoneParser {
                                String albumImageId = albumXml.getValue("album-image", null);
                                if ((id == null) || (title == null) || (description == null)) {
                                        logger.log(Level.WARNING, String.format("Downloaded Sone %s contains invalid album!", sone));
-                                       return null;
+                                       throw new MalformedXml();
                                }
                                Album parent = sone.getRootAlbum();
                                if (parentId != null) {
                                        parent = albums.get(parentId);
                                        if (parent == null) {
                                                logger.log(Level.WARNING, String.format("Downloaded Sone %s has album with invalid parent!", sone));
-                                               return null;
+                                               throw new InvalidParentAlbum();
                                        }
                                }
                                Album album = parent.newAlbumBuilder().withId(id).build().modify().setTitle(title).setDescription(description).update();
@@ -363,4 +363,9 @@ public class SoneParser {
        public static class MalformedTime extends RuntimeException {
 
        }
+
+       public static class InvalidParentAlbum extends RuntimeException {
+
+       }
+
 }