From d2523812587e6f4c828958692ab921bdb95c9a37 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Fri, 6 Dec 2024 04:42:39 -0800 Subject: [PATCH] Clarify failure message when testing existence. --- GLOBALS.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GLOBALS.mjs b/GLOBALS.mjs index fee5333..0ed94e8 100644 --- a/GLOBALS.mjs +++ b/GLOBALS.mjs @@ -60,7 +60,8 @@ export const assert = { }, exists: (a) => { if (a == null) { - throw new Error(`argument is ${typeof a}`) + const type = /^[aeiou]/i.test(typeof a) ? `an ${typeof a}` : `a ${typeof a}` + throw new Error(`argument exists and is ${type}`) } return a != null }, -- 2.34.1