mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-19 15:54:09 +02:00
MISC: Handle error when getting save data (#1241)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user