catch read save area errors
This commit is contained in:
parent
301e0ac32e
commit
f38501acb7
6 changed files with 18 additions and 12 deletions
|
|
@ -826,18 +826,24 @@ function CheckHintsTrue(divId, dataObject, playerData, worldData) {
|
|||
/**
|
||||
* Pre-Cleans HTML. Reads contents inside text area and parses it to a JavaScript object. If not empty, runs HKCheckCompletion() to check data.
|
||||
*/
|
||||
function HKReadTextArea() {
|
||||
function HKReadTextArea(textAreaId = "") {
|
||||
|
||||
// refresh and prepare document for filling with data from the save
|
||||
InitialHTMLPopulate(HK.DIV_ID);
|
||||
|
||||
let textAreaId = "save-area";
|
||||
let contents = document.getElementById(textAreaId).value;
|
||||
|
||||
if (contents.length) {
|
||||
|
||||
let jsonObject = JSON.parse(contents);
|
||||
// console.log(jsonObject);
|
||||
if (jsonObject.hasOwnProperty("playerData")) HKCheckCompletion(jsonObject);
|
||||
// console.log(jsonObject);
|
||||
try {
|
||||
let jsonObject = JSON.parse(contents);
|
||||
// console.log(jsonObject);
|
||||
if (jsonObject.hasOwnProperty("playerData")) HKCheckCompletion(jsonObject);
|
||||
// console.log(jsonObject);
|
||||
} catch (error) {
|
||||
alert(`This seems like not a valid Hollow Knight save. ${error}`);
|
||||
console.info(`This seems like not a valid Hollow Knight save. ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ function ProcessFileObject() {
|
|||
console.info("LoadSaveFile() time (ms) =", benchLSFEnd - benchLSFBegin);
|
||||
|
||||
// after pasting the decoded string, launch the main analyzing function immediately
|
||||
HKReadTextArea();
|
||||
HKReadTextArea("save-area");
|
||||
|
||||
// finish total and show benchmark
|
||||
benchTotal = new Date();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue