mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-25 15:42:28 +01:00
rm any
This commit is contained in:
parent
a0994a088c
commit
c9432e4cd7
@ -10,7 +10,7 @@ import { Factions } from "../Faction/Factions";
|
|||||||
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
||||||
import { Reviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "../utils/JSONReviver";
|
import { Reviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "../utils/JSONReviver";
|
||||||
|
|
||||||
import { exceptionAlert } from "../utils/helpers/exceptionAlert";
|
import { exceptionAlert, isIError } from "../utils/helpers/exceptionAlert";
|
||||||
import { getRandomInt } from "../utils/helpers/getRandomInt";
|
import { getRandomInt } from "../utils/helpers/getRandomInt";
|
||||||
|
|
||||||
import { GangMemberUpgrade } from "./GangMemberUpgrade";
|
import { GangMemberUpgrade } from "./GangMemberUpgrade";
|
||||||
@ -99,7 +99,7 @@ export class Gang implements IGang {
|
|||||||
this.processExperienceGains(cycles);
|
this.processExperienceGains(cycles);
|
||||||
this.processTerritoryAndPowerGains(cycles);
|
this.processTerritoryAndPowerGains(cycles);
|
||||||
this.storedCycles -= cycles;
|
this.storedCycles -= cycles;
|
||||||
} catch (e: any) {
|
} catch (e: unknown) {
|
||||||
console.error(`Exception caught when processing Gang: ${e}`);
|
console.error(`Exception caught when processing Gang: ${e}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -358,7 +358,7 @@ export class Gang implements IGang {
|
|||||||
workerScript.log("gang.ascendMember", () => `Ascended Gang member ${member.name}`);
|
workerScript.log("gang.ascendMember", () => `Ascended Gang member ${member.name}`);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
} catch (e: any) {
|
} catch (e: unknown) {
|
||||||
if (workerScript == null) {
|
if (workerScript == null) {
|
||||||
exceptionAlert(e);
|
exceptionAlert(e);
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
* - Adds brackets around the array
|
* - Adds brackets around the array
|
||||||
* - Adds quotation marks around strings
|
* - Adds quotation marks around strings
|
||||||
*/
|
*/
|
||||||
export function arrayToString<T>(a: T[]): string {
|
export function arrayToString(a: unknown[]): string {
|
||||||
const vals: any[] = [];
|
const vals: unknown[] = [];
|
||||||
for (let i = 0; i < a.length; ++i) {
|
for (let i = 0; i < a.length; ++i) {
|
||||||
let elem: any = a[i];
|
let elem: unknown = a[i];
|
||||||
if (Array.isArray(elem)) {
|
if (Array.isArray(elem)) {
|
||||||
elem = arrayToString(elem);
|
elem = arrayToString(elem);
|
||||||
} else if (typeof elem === "string") {
|
} else if (typeof elem === "string") {
|
||||||
|
@ -5,17 +5,21 @@ interface IError {
|
|||||||
lineNumber?: number;
|
lineNumber?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function exceptionAlert(e: IError | string): void {
|
export const isIError = (v: unknown): v is IError => {
|
||||||
|
if (typeof v !== "object" || v == null) return false;
|
||||||
|
return v.hasOwnProperty("fileName") && v.hasOwnProperty("lineNumber");
|
||||||
|
};
|
||||||
|
|
||||||
|
export function exceptionAlert(e: unknown): void {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
let msg = "";
|
let msg = "";
|
||||||
let file = "UNKNOWN FILE NAME";
|
let file = "UNKNOWN FILE NAME";
|
||||||
let line = "UNKNOWN LINE NUMBER";
|
let line = "UNKNOWN LINE NUMBER";
|
||||||
const isError = (e: IError | string): e is IError => e.hasOwnProperty("fileName");
|
if (isIError(e)) {
|
||||||
if (isError(e)) {
|
|
||||||
file = e.fileName ?? file;
|
file = e.fileName ?? file;
|
||||||
line = e.lineNumber?.toString() ?? line;
|
line = e.lineNumber?.toString() ?? line;
|
||||||
} else {
|
} else {
|
||||||
msg = e;
|
msg = String(e);
|
||||||
}
|
}
|
||||||
dialogBoxCreate(
|
dialogBoxCreate(
|
||||||
"Caught an exception: " +
|
"Caught an exception: " +
|
||||||
|
Loading…
Reference in New Issue
Block a user