From cf6b52780cfab19da9f75882fbe11e7a0735d041 Mon Sep 17 00:00:00 2001 From: Maschell Date: Wed, 10 Apr 2019 18:08:04 +0200 Subject: [PATCH] Throw a ParseException on error in the FST and FSTService --- src/de/mas/wiiu/jnus/entities/fst/FST.java | 8 ++++---- src/de/mas/wiiu/jnus/entities/fst/FSTService.java | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/de/mas/wiiu/jnus/entities/fst/FST.java b/src/de/mas/wiiu/jnus/entities/fst/FST.java index eef2770..fcd30f3 100644 --- a/src/de/mas/wiiu/jnus/entities/fst/FST.java +++ b/src/de/mas/wiiu/jnus/entities/fst/FST.java @@ -16,6 +16,7 @@ ****************************************************************************/ package de.mas.wiiu.jnus.entities.fst; +import java.text.ParseException; import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -52,12 +53,11 @@ public final class FST { * @param contentsMappedByIndex * map of index/content * @return + * @throws ParseException */ - public static FST parseFST(byte[] fstData, Map contentsMappedByIndex) { + public static FST parseFST(byte[] fstData, Map contentsMappedByIndex) throws ParseException { if (!Arrays.equals(Arrays.copyOfRange(fstData, 0, 3), new byte[] { 0x46, 0x53, 0x54 })) { - throw new RuntimeException("Failed to parse FST"); - // return null; - // throw new IllegalArgumentException("Not a FST. Maybe a wrong key?"); + throw new ParseException("Failed to parse FST",0); } int sectorSize = ByteUtils.getIntFromBytes(fstData, 0x04); diff --git a/src/de/mas/wiiu/jnus/entities/fst/FSTService.java b/src/de/mas/wiiu/jnus/entities/fst/FSTService.java index 692a54c..8c3078e 100644 --- a/src/de/mas/wiiu/jnus/entities/fst/FSTService.java +++ b/src/de/mas/wiiu/jnus/entities/fst/FSTService.java @@ -16,6 +16,7 @@ ****************************************************************************/ package de.mas.wiiu.jnus.entities.fst; +import java.text.ParseException; import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -33,7 +34,7 @@ public final class FSTService { } public static void parseFST(FSTEntry rootEntry, byte[] fstSection, byte[] namesSection, Map contentsByIndex, - Map contentsFSTByIndex, int sectorSize) { + Map contentsFSTByIndex, int sectorSize) throws ParseException { int totalEntries = ByteUtils.getIntFromBytes(fstSection, 0x08); int level = 0; @@ -103,12 +104,14 @@ public final class FSTService { Content content = contentsByIndex.get((int) contentIndex); if (content == null) { log.warning("Content for FST Entry not found"); + throw new ParseException("Content for FST Entry not found", 0); } else { entryParam.setContent(content); ContentFSTInfo contentFSTInfo = contentsFSTByIndex.get((int) contentIndex); if (contentFSTInfo == null) { log.warning("ContentFSTInfo for FST Entry not found"); + throw new ParseException("ContentFSTInfo for FST Entry not found", 0); } else { content.setContentFSTInfo(contentFSTInfo); }