This commit is contained in:
Olivier Gagnon
2022-07-14 21:54:49 -04:00
parent a0994a088c
commit c9432e4cd7
3 changed files with 14 additions and 10 deletions
+3 -3
View File
@@ -5,10 +5,10 @@
* - Adds brackets around the array
* - Adds quotation marks around strings
*/
export function arrayToString<T>(a: T[]): string {
const vals: any[] = [];
export function arrayToString(a: unknown[]): string {
const vals: unknown[] = [];
for (let i = 0; i < a.length; ++i) {
let elem: any = a[i];
let elem: unknown = a[i];
if (Array.isArray(elem)) {
elem = arrayToString(elem);
} else if (typeof elem === "string") {
+8 -4
View File
@@ -5,17 +5,21 @@ interface IError {
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);
let msg = "";
let file = "UNKNOWN FILE NAME";
let line = "UNKNOWN LINE NUMBER";
const isError = (e: IError | string): e is IError => e.hasOwnProperty("fileName");
if (isError(e)) {
if (isIError(e)) {
file = e.fileName ?? file;
line = e.lineNumber?.toString() ?? line;
} else {
msg = e;
msg = String(e);
}
dialogBoxCreate(
"Caught an exception: " +