MISC: Handle error when getting save data (#1241)

This commit is contained in:
catloversg
2024-05-09 16:19:30 +07:00
committed by GitHub
parent bfb9841832
commit aef362204d
4 changed files with 47 additions and 4 deletions
+13
View File
@@ -105,3 +105,16 @@ export function handleUnknownError(e: unknown, ws: WorkerScript | ScriptDeath |
}
dialogBoxCreate(initialText + e);
}
/** Use this handler to handle the error when we call getSaveData function */
export function handleGetSaveDataError(error: unknown) {
console.error(error);
let errorMessage = `Cannot get save data. Error: ${error}.`;
if (error instanceof RangeError) {
errorMessage += " This may be because the save data is too large.";
}
if (error instanceof Error && error.stack) {
errorMessage += `\nStack:\n${error.stack}`;
}
dialogBoxCreate(errorMessage);
}