chore: Clarify error messages.

This commit is contained in:
Ruben Verborgh
2022-06-23 14:42:44 +01:00
committed by Joachim Van Herwegen
parent 82f90709a6
commit ba40374c66
2 changed files with 4 additions and 4 deletions

View File

@@ -92,10 +92,10 @@ class WebSocketListener extends EventEmitter {
// Resolve and verify the URL
const resolved = new URL(path, `${this.protocol}${this.host}`);
if (resolved.host !== this.host) {
throw new Error(`Mismatched host: ${resolved.host} instead of ${this.host}`);
throw new Error(`Mismatched host: expected ${this.host} but got ${resolved.host}`);
}
if (resolved.protocol !== this.protocol) {
throw new Error(`Mismatched protocol: ${resolved.protocol} instead of ${this.protocol}`);
throw new Error(`Mismatched protocol: expected ${this.protocol} but got ${resolved.protocol}`);
}
// Subscribe to the URL
const url = resolved.href;

View File

@@ -101,7 +101,7 @@ describe('An UnsecureWebSocketsProtocol', (): void => {
it('send an error message.', (): void => {
expect(webSocket.messages).toHaveLength(1);
expect(webSocket.messages.shift())
.toBe('error Mismatched host: wrong.example instead of mypod.example');
.toBe('error Mismatched host: expected mypod.example but got wrong.example');
});
});
@@ -113,7 +113,7 @@ describe('An UnsecureWebSocketsProtocol', (): void => {
it('send an error message.', (): void => {
expect(webSocket.messages).toHaveLength(1);
expect(webSocket.messages.shift())
.toBe('error Mismatched protocol: http: instead of https:');
.toBe('error Mismatched protocol: expected https: but got http:');
});
});
});