1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

refactor(ext/webidl): align error messages (#25625)

Towards https://github.com/denoland/deno/issues/25269
This commit is contained in:
Ian Bull 2024-09-19 00:33:32 -07:00 committed by GitHub
parent 0ea71abdef
commit 3035cdddb8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View file

@ -712,7 +712,7 @@ function requiredArguments(length, required, prefix) {
if (length < required) { if (length < required) {
const errMsg = `${prefix ? prefix + ": " : ""}${required} argument${ const errMsg = `${prefix ? prefix + ": " : ""}${required} argument${
required === 1 ? "" : "s" required === 1 ? "" : "s"
} required, but only ${length} present.`; } required, but only ${length} present`;
throw new TypeError(errMsg); throw new TypeError(errMsg);
} }
} }
@ -818,7 +818,7 @@ function createDictionaryConverter(name, ...dictionaries) {
} else if (member.required) { } else if (member.required) {
throw makeException( throw makeException(
TypeError, TypeError,
`can not be converted to '${name}' because '${key}' is required in '${name}'.`, `can not be converted to '${name}' because '${key}' is required in '${name}'`,
prefix, prefix,
context, context,
); );
@ -845,7 +845,7 @@ function createEnumConverter(name, values) {
throw new TypeError( throw new TypeError(
`${ `${
prefix ? prefix + ": " : "" prefix ? prefix + ": " : ""
}The provided value '${S}' is not a valid enum value of type ${name}.`, }The provided value '${S}' is not a valid enum value of type ${name}`,
); );
} }
@ -925,7 +925,7 @@ function createRecordConverter(keyConverter, valueConverter) {
if (type(V) !== "Object") { if (type(V) !== "Object") {
throw makeException( throw makeException(
TypeError, TypeError,
"can not be converted to dictionary.", "can not be converted to dictionary",
prefix, prefix,
context, context,
); );
@ -996,7 +996,7 @@ function createInterfaceConverter(name, prototype) {
if (!ObjectPrototypeIsPrototypeOf(prototype, V) || V[brand] !== brand) { if (!ObjectPrototypeIsPrototypeOf(prototype, V) || V[brand] !== brand) {
throw makeException( throw makeException(
TypeError, TypeError,
`is not of type ${name}.`, `is not of type ${name}`,
prefix, prefix,
context, context,
); );

View file

@ -1,4 +1,4 @@
[WILDCARD]error: Uncaught (in promise) TypeError: Failed to construct 'Event': 1 argument required, but only 0 present. [WILDCARD]error: Uncaught (in promise) TypeError: Failed to construct 'Event': 1 argument required, but only 0 present
new Event(); new Event();
^ ^
at [WILDCARD] at [WILDCARD]