From: Chris Duncan Date: Fri, 6 Dec 2024 12:42:39 +0000 (-0800) Subject: Clarify failure message when testing existence. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=d2523812587e6f4c828958692ab921bdb95c9a37;p=libnemo.git Clarify failure message when testing existence. --- 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 },