mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 08:50:51 +01:00
Better error handling in figureData parser
This commit is contained in:
parent
df20ea3e32
commit
0b4a5b000f
@ -29,7 +29,7 @@ public class Figuredata {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws SAXException
|
* @throws SAXException
|
||||||
*/
|
*/
|
||||||
public void parseXML(String uri) throws ParserConfigurationException, IOException, SAXException {
|
public void parseXML(String uri) throws Exception, ParserConfigurationException, IOException, SAXException {
|
||||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
factory.setValidating(false);
|
factory.setValidating(false);
|
||||||
factory.setIgnoringElementContentWhitespace(true);
|
factory.setIgnoringElementContentWhitespace(true);
|
||||||
@ -37,6 +37,15 @@ public class Figuredata {
|
|||||||
Document document = builder.parse(uri);
|
Document document = builder.parse(uri);
|
||||||
|
|
||||||
Element rootElement = document.getDocumentElement();
|
Element rootElement = document.getDocumentElement();
|
||||||
|
|
||||||
|
if(!rootElement.getTagName().equalsIgnoreCase("figuredata")) {
|
||||||
|
throw new Exception("The passed file is not in figuredata format. Received " + document.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(document.getElementsByTagName("colors") == null || document.getElementsByTagName("sets") == null) {
|
||||||
|
throw new Exception("The passed file is not in figuredata format. Received " + document.toString());
|
||||||
|
}
|
||||||
|
|
||||||
NodeList palettesList = document.getElementsByTagName("colors").item(0).getChildNodes();
|
NodeList palettesList = document.getElementsByTagName("colors").item(0).getChildNodes();
|
||||||
NodeList settypesList = document.getElementsByTagName("sets").item(0).getChildNodes();
|
NodeList settypesList = document.getElementsByTagName("sets").item(0).getChildNodes();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user