From 15e3b751da7769c9628a684ec33b18c5a5fe0cd2 Mon Sep 17 00:00:00 2001 From: Steven Evans Date: Wed, 4 Jul 2018 00:54:11 -0400 Subject: [PATCH] [refactor] Moved "exceptionAlert" to its own TS file Since this is a UI only function, when Web Workers are introduced this call chain will not be allowed on the backend. --- src/ActiveScriptsUI.js | 3 ++- src/Bladeburner.js | 3 ++- src/CinematicText.js | 3 ++- src/Prestige.js | 3 ++- src/engine.js | 4 ++-- utils/HelperFunctions.js | 12 ------------ utils/helpers/exceptionAlert.js | 16 ++++++++++++++++ 7 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 utils/helpers/exceptionAlert.js diff --git a/src/ActiveScriptsUI.js b/src/ActiveScriptsUI.js index 54b48dc0f..ec0d08cce 100644 --- a/src/ActiveScriptsUI.js +++ b/src/ActiveScriptsUI.js @@ -7,7 +7,8 @@ import {getServer} from "./Server"; import {dialogBoxCreate} from "../utils/DialogBox"; import {printArray, createElement, createAccordionElement, removeElement, - removeChildrenFromElement, exceptionAlert} from "../utils/HelperFunctions"; + removeChildrenFromElement} from "../utils/HelperFunctions"; +import {exceptionAlert} from "../utils/helpers/exceptionAlert"; import {logBoxCreate} from "../utils/LogBox"; import numeral from "numeral/min/numeral.min"; import {formatNumber} from "../utils/StringHelperFunctions"; diff --git a/src/Bladeburner.js b/src/Bladeburner.js index 894c60c43..8d8d5c03f 100644 --- a/src/Bladeburner.js +++ b/src/Bladeburner.js @@ -13,11 +13,12 @@ import {createProgressBarText} from "../utils/helpers/creat import {dialogBoxCreate} from "../utils/DialogBox"; import {getRandomInt, addOffset, clearObject, createElement, removeChildrenFromElement, - exceptionAlert, createPopup, appendLineBreaks, + createPopup, appendLineBreaks, removeElementById, removeElement} from "../utils/HelperFunctions"; import {Reviver, Generic_toJSON, Generic_fromJSON} from "../utils/JSONReviver"; import numeral from "numeral/min/numeral.min"; +import {exceptionAlert} from "../utils/helpers/exceptionAlert"; import {formatNumber} from "../utils/StringHelperFunctions"; diff --git a/src/CinematicText.js b/src/CinematicText.js index 466432af7..d82bc6e2c 100644 --- a/src/CinematicText.js +++ b/src/CinematicText.js @@ -1,7 +1,8 @@ import {Engine} from "./engine"; import {removeChildrenFromElement, - createElement, exceptionAlert} from "../utils/HelperFunctions"; + createElement} from "../utils/HelperFunctions"; +import {exceptionAlert} from "../utils/helpers/exceptionAlert"; import {isString} from "../utils/helpers/isString"; var cinematicTextFlag = false; diff --git a/src/Prestige.js b/src/Prestige.js index a1c93d76d..6f113901f 100644 --- a/src/Prestige.js +++ b/src/Prestige.js @@ -31,7 +31,8 @@ import {Terminal, postNetburnerText} from "./Terminal"; import Decimal from "decimal.js"; import {dialogBoxCreate} from "../utils/DialogBox"; import {createPopup, createElement, - removeElementById, exceptionAlert} from "../utils/HelperFunctions"; + removeElementById} from "../utils/HelperFunctions"; +import {exceptionAlert} from "../utils/helpers/exceptionAlert"; import {yesNoBoxCreate, yesNoBoxGetYesButton, yesNoBoxGetNoButton, yesNoBoxClose} from "../utils/YesNoBox"; diff --git a/src/engine.js b/src/engine.js index f92ef8047..979d01289 100644 --- a/src/engine.js +++ b/src/engine.js @@ -1,8 +1,8 @@ import {dialogBoxCreate} from "../utils/DialogBox"; import {gameOptionsBoxOpen, gameOptionsBoxClose}from "../utils/GameOptions"; import {clearEventListeners, createElement, - removeChildrenFromElement, - exceptionAlert} from "../utils/HelperFunctions"; + removeChildrenFromElement} from "../utils/HelperFunctions"; +import {exceptionAlert} from "../utils/helpers/exceptionAlert"; import numeral from "numeral/min/numeral.min"; import {formatNumber, convertTimeMsToTimeElapsedString, diff --git a/utils/HelperFunctions.js b/utils/HelperFunctions.js index dcf6c1e45..8647046b3 100644 --- a/utils/HelperFunctions.js +++ b/utils/HelperFunctions.js @@ -1,6 +1,5 @@ //General helper functions import {isString} from "./helpers/isString"; -import {dialogBoxCreate} from "./DialogBox"; //Returns the size (number of keys) of an object function sizeOfObject(obj) { @@ -248,16 +247,6 @@ function roundToTwo(n) { return +(Math.round(n + "e+2") + "e-2"); } -function exceptionAlert(e) { - dialogBoxCreate("Caught an exception: " + e + "

" + - "Filename: " + e.fileName + "

" + - "Line Number: " + e.lineNumber + "

" + - "This is a bug, please report to game developer with this " + - "message as well as details about how to reproduce the bug.

" + - "If you want to be safe, I suggest refreshing the game WITHOUT saving so that your " + - "safe doesn't get corrupted"); -} - export {sizeOfObject, clearObject, addOffset, @@ -276,5 +265,4 @@ export {sizeOfObject, removeChildrenFromElement, createPopup, clearSelector, - exceptionAlert, getElementById}; diff --git a/utils/helpers/exceptionAlert.js b/utils/helpers/exceptionAlert.js new file mode 100644 index 000000000..e652cd8e9 --- /dev/null +++ b/utils/helpers/exceptionAlert.js @@ -0,0 +1,16 @@ +import { dialogBoxCreate } from "../DialogBox"; + +function exceptionAlert(e) { + dialogBoxCreate("Caught an exception: " + e + "

" + + "Filename: " + (e.fileName || "UNKNOWN FILE NAME") + "

" + + "Line Number: " + (e.lineNumber || "UNKNOWN LINE NUMBER") + "

" + + "This is a bug, please report to game developer with this " + + "message as well as details about how to reproduce the bug.

" + + "If you want to be safe, I suggest refreshing the game WITHOUT saving so that your " + + "safe doesn't get corrupted"); +} + + +export { + exceptionAlert +} \ No newline at end of file