better error dialog

This commit is contained in:
Downforce Agent 2024-08-02 17:00:29 -05:00
parent a17f7d1b58
commit b3a949fe43

View File

@ -89,7 +89,7 @@ public class Rizzo {
File newCtx = new File(workingDir + args[1]); File newCtx = new File(workingDir + args[1]);
System.out.println("Calling new parse: " + Arrays.toString(Arrays.copyOfRange(args, 2, args.length))); System.out.println("Calling new parse: " + Arrays.toString(Arrays.copyOfRange(args, 2, args.length)));
parseArgs(Arrays.copyOfRange(args, 2, args.length), newCtx); parseArgs(Arrays.copyOfRange(args, 2, args.length), newCtx);
} else throw new FirescriptFormatException("fscript", "unknown command '" + args[0] + "'"); } else throw new FirescriptFormatException("fscript", "command '" + args[0] + "' is unknown or used in inappropriate context\n\nOne of your mods has a broken FSCRIPT. It cannot be installed.");
} else { } else {
System.out.println("Parsing Command: " + Arrays.toString(args) + " using context: " + context.getClass().getName() + "@" + context.hashCode()); System.out.println("Parsing Command: " + Arrays.toString(args) + " using context: " + context.getClass().getName() + "@" + context.hashCode());
if (args[0].equals("{")) { if (args[0].equals("{")) {
@ -132,7 +132,7 @@ public class Rizzo {
Logger.getLogger(Rizzo.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(Rizzo.class.getName()).log(Level.SEVERE, null, ex);
} }
} catch (SAXException | IOException | ParserConfigurationException ex) { } catch (SAXException | IOException | ParserConfigurationException ex) {
Logger.getLogger(Rizzo.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(Rizzo.class.getName()).log(Level.SEVERE, "This usually means there's non-standard formatting from the game developer which your FSCRIPT does not account for.", ex);
} }
} else if (args[0].equalsIgnoreCase("str") || args[0].equalsIgnoreCase("xstr")) { } else if (args[0].equalsIgnoreCase("str") || args[0].equalsIgnoreCase("xstr")) {
try { try {
@ -199,7 +199,7 @@ public class Rizzo {
} catch (FirescriptFormatException | PatchFailedException | IOException ex) { } catch (FirescriptFormatException | PatchFailedException | IOException ex) {
Logger.getLogger(Rizzo.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(Rizzo.class.getName()).log(Level.SEVERE, null, ex);
} }
} else throw new FirescriptFormatException("file", "unknown command '" + args[0] + "'"); } else throw new FirescriptFormatException("file", "command '" + args[0] + "' is unknown or used in inappropriate context\n\nOne of your mods has a broken FSCRIPT. It cannot be installed.");
} else if (args[0].equalsIgnoreCase("xml")) { } else if (args[0].equalsIgnoreCase("xml")) {
System.out.println("fscript: XML called but file does not exist. Using placebo..."); System.out.println("fscript: XML called but file does not exist. Using placebo...");
try { try {
@ -234,7 +234,7 @@ public class Rizzo {
try { try {
DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
ReplacingInputStream ris = new ReplacingInputStream(new ReplacingInputStream(new ReplacingInputStream(new FileInputStream(new File(workingDir + args[1])), "\r\n", ""), "&", "&"), "\n", "
"); ReplacingInputStream ris = new ReplacingInputStream(new ReplacingInputStream(new ReplacingInputStream(new FileInputStream(new File(workingDir + args[1])), "\r\n", ""), "&", "&"), "\n", "
");
Document outDoc = docBuilder.parse(ris); Document outDoc = docBuilder.parse(ris); // throw new FirescriptFormatException("xml", "javax.xml.parsers self-destructed with error:\n" + e.getMessage() + "\nThis usually means you used a bad FSCRIPT, or there was non-standard formatting from the game developer.");
NamedNodeMap nnm = outDoc.getDocumentElement().getAttributes(); NamedNodeMap nnm = outDoc.getDocumentElement().getAttributes();
for (int x = 0; x < nnm.getLength(); x++) { for (int x = 0; x < nnm.getLength(); x++) {
@ -248,9 +248,9 @@ public class Rizzo {
document.getDocumentElement().appendChild(importedNode); document.getDocumentElement().appendChild(importedNode);
} }
} catch (SAXException | IOException | ParserConfigurationException ex) { } catch (SAXException | IOException | ParserConfigurationException ex) {
Logger.getLogger(Rizzo.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(Rizzo.class.getName()).log(Level.SEVERE, "This usually means there's non-standard formatting from the game developer which your FSCRIPT does not account for.", ex);
} }
} else throw new FirescriptFormatException("xml", "unknown command '" + args[0] + "'"); } else throw new FirescriptFormatException("xml", "command '" + args[0] + "' is unknown or used in inappropriate context\n\nOne of your mods has a broken FSCRIPT. It cannot be installed.");
} else { } else {
System.out.println("fscript: XML document has no child nodes. Skipping..."); System.out.println("fscript: XML document has no child nodes. Skipping...");
parseArgs(Arrays.copyOfRange(args, 1, args.length), document); parseArgs(Arrays.copyOfRange(args, 1, args.length), document);