From 1950f5af971d3022792690bf8ee02c2777eebe42 Mon Sep 17 00:00:00 2001 From: Miika Alonen Date: Tue, 12 Dec 2023 02:41:00 +0200 Subject: [PATCH] Add better error handling for zifferjs --- src/API.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/API.ts b/src/API.ts index 6e4a69d..6d5bfa1 100644 --- a/src/API.ts +++ b/src/API.ts @@ -718,13 +718,13 @@ export class UserAPI { input: string | Generator, options: InputOptions = {}, id: number | string = "", - ): Player|undefined => { + ): Player => { const zid = "z" + id.toString(); const key = id === "" ? this.generateCacheKey(input, options) : zid; const validSyntax = typeof input === "string" && !this.invalidPatterns[input] if(!validSyntax) this.app.api.log(`Invalid syntax: ${input}`); - + let player; let replace = false; @@ -765,7 +765,7 @@ export class UserAPI { return player; } else { - return undefined; + throw new Error(`Invalid syntax: ${input}`); } };