Error message fixes

This commit is contained in:
omuretsu 2022-10-14 11:08:24 -04:00
parent 7683990d17
commit 9908f4aaa5
2 changed files with 3 additions and 3 deletions

@ -1758,11 +1758,11 @@ const base: InternalAPI<NS> = {
_options ??= options;
const txt = helpers.string(ctx, "txt", _txt);
assert(_options, objectAssert, (type) =>
helpers.makeRuntimeErrorMsg(ctx, `Invalid type for options: ${type}, should be object.`, "TYPE"),
helpers.makeRuntimeErrorMsg(ctx, `Invalid type for options: ${type}. Should be object.`, "TYPE"),
);
if (_options.type !== undefined) {
assert(_options.type, stringAssert, (type) =>
helpers.makeRuntimeErrorMsg(ctx, `Invalid type for options.type: ${type}, should be string.`, "TYPE"),
helpers.makeRuntimeErrorMsg(ctx, `Invalid type for options.type: ${type}. Should be string.`, "TYPE"),
);
options.type = _options.type;
const validTypes = ["boolean", "text", "select"];

@ -12,7 +12,7 @@ export function assert<T>(
try {
assertFn(v);
} catch (type: unknown) {
if (type !== "string") type = "unknown";
if (typeof type !== "string") type = "unknown";
throw msgFn(type as string);
}
}