From 70d45e80faffd91121c2e17da5a85a2ebc8a7f2d Mon Sep 17 00:00:00 2001 From: Maschell Date: Wed, 10 Apr 2019 17:57:15 +0200 Subject: [PATCH] Throw exceptions instead returning null in the WoomyParser --- .../mas/wiiu/jnus/implementations/woomy/WoomyParser.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/de/mas/wiiu/jnus/implementations/woomy/WoomyParser.java b/src/de/mas/wiiu/jnus/implementations/woomy/WoomyParser.java index 4c08b35..f82c45b 100644 --- a/src/de/mas/wiiu/jnus/implementations/woomy/WoomyParser.java +++ b/src/de/mas/wiiu/jnus/implementations/woomy/WoomyParser.java @@ -17,6 +17,7 @@ package de.mas.wiiu.jnus.implementations.woomy; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.text.ParseException; import java.util.Enumeration; @@ -53,14 +54,14 @@ public final class WoomyParser { WoomyInfo result = new WoomyInfo(); if (!woomyFile.exists()) { log.info("File does not exist." + woomyFile.getAbsolutePath()); - return null; + throw new FileNotFoundException("File does not exist." + woomyFile.getAbsolutePath()); } try (ZipFile zipFile = new ZipFile(woomyFile)) { result.setWoomyFile(woomyFile); ZipEntry metaFile = zipFile.getEntry(Settings.WOOMY_METADATA_FILENAME); if (metaFile == null) { log.info("No meta "); - return null; + throw new FileNotFoundException("No \""+ Settings.WOOMY_METADATA_FILENAME +"\" inside woomy was found."); } WoomyMeta meta = WoomyMetaParser.parseMeta(zipFile.getInputStream(metaFile)); @@ -68,7 +69,7 @@ public final class WoomyParser { * Currently we will only use the first entry in the metadata.xml */ if (meta.getEntries().isEmpty()) { - return null; + throw new FileNotFoundException("WoomyMeta has no entries"); } WoomyEntry entry = meta.getEntries().get(0); String regEx = entry.getFolder() + ".*"; // We want all files in the entry fodler @@ -77,6 +78,7 @@ public final class WoomyParser { } catch (ZipException e) { log.info("Caught Execption : " + e.getMessage()); + throw new ParseException("Failed to parse woomy:" + e.getMessage(), 0); } return result; }