mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
refactor(ext/websocket): align error messages (#25622)
Aligns the error messages in the ext/websocket folder to be in-line with the Deno style guide. https://github.com/denoland/deno/issues/25269
This commit is contained in:
parent
f360cae9dd
commit
97b8c9be38
1 changed files with 7 additions and 7 deletions
|
@ -161,14 +161,14 @@ class WebSocket extends EventTarget {
|
||||||
|
|
||||||
if (wsURL.protocol !== "ws:" && wsURL.protocol !== "wss:") {
|
if (wsURL.protocol !== "ws:" && wsURL.protocol !== "wss:") {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"Only ws & wss schemes are allowed in a WebSocket URL.",
|
`Only ws & wss schemes are allowed in a WebSocket URL: received ${wsURL.protocol}`,
|
||||||
"SyntaxError",
|
"SyntaxError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wsURL.hash !== "" || StringPrototypeEndsWith(wsURL.href, "#")) {
|
if (wsURL.hash !== "" || StringPrototypeEndsWith(wsURL.href, "#")) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"Fragments are not allowed in a WebSocket URL.",
|
"Fragments are not allowed in a WebSocket URL",
|
||||||
"SyntaxError",
|
"SyntaxError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ class WebSocket extends EventTarget {
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"Can't supply multiple times the same protocol.",
|
"Cannot supply multiple times the same protocol",
|
||||||
"SyntaxError",
|
"SyntaxError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ class WebSocket extends EventTarget {
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"Invalid protocol value.",
|
"Invalid protocol value",
|
||||||
"SyntaxError",
|
"SyntaxError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ class WebSocket extends EventTarget {
|
||||||
data = webidl.converters.WebSocketSend(data, prefix, "Argument 1");
|
data = webidl.converters.WebSocketSend(data, prefix, "Argument 1");
|
||||||
|
|
||||||
if (this[_readyState] !== OPEN) {
|
if (this[_readyState] !== OPEN) {
|
||||||
throw new DOMException("readyState not OPEN", "InvalidStateError");
|
throw new DOMException("'readyState' not OPEN", "InvalidStateError");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this[_sendQueue].length === 0) {
|
if (this[_sendQueue].length === 0) {
|
||||||
|
@ -376,7 +376,7 @@ class WebSocket extends EventTarget {
|
||||||
!(code === 1000 || (3000 <= code && code < 5000))
|
!(code === 1000 || (3000 <= code && code < 5000))
|
||||||
) {
|
) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"The close code must be either 1000 or in the range of 3000 to 4999.",
|
`The close code must be either 1000 or in the range of 3000 to 4999: received ${code}`,
|
||||||
"InvalidAccessError",
|
"InvalidAccessError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -387,7 +387,7 @@ class WebSocket extends EventTarget {
|
||||||
TypedArrayPrototypeGetByteLength(core.encode(reason)) > 123
|
TypedArrayPrototypeGetByteLength(core.encode(reason)) > 123
|
||||||
) {
|
) {
|
||||||
throw new DOMException(
|
throw new DOMException(
|
||||||
"The close reason may not be longer than 123 bytes.",
|
"The close reason may not be longer than 123 bytes",
|
||||||
"SyntaxError",
|
"SyntaxError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue