Skip to content

Commit b90e127

Browse files
authored
chore: make JavaScript WebSocket client throw errors on schema compilation failure (#1854)
Co-authored-by: Harsh Gupta <harsh16official@gmail.com>
1 parent db503dc commit b90e127

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

packages/templates/clients/websocket/javascript/components/CompileOperationSchemas.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ async compileOperationSchemas() {
3131
console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));
3232
} catch (error) {
3333
console.error('Error initializing schemas:', error);
34+
this.schemasCompiled = false;
35+
if (error instanceof Error) {
36+
error.message = \`Schema compilation failed: \${error.message}\`;
37+
throw error;
38+
} else {
39+
throw new Error(\`Schema compilation failed: \${String(error)}\`);
40+
}
3441
}
3542
}`
3643
}

packages/templates/clients/websocket/test/integration-test/__snapshots__/integration.test.js.snap

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6283,6 +6283,13 @@ class HoppscotchClient {
62836283
console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));
62846284
} catch (error) {
62856285
console.error('Error initializing schemas:', error);
6286+
this.schemasCompiled = false;
6287+
if (error instanceof Error) {
6288+
error.message = \`Schema compilation failed: \${error.message}\`;
6289+
throw error;
6290+
} else {
6291+
throw new Error(\`Schema compilation failed: \${String(error)}\`);
6292+
}
62866293
}
62876294
}
62886295
@@ -6647,6 +6654,13 @@ class HoppscotchEchoWebSocketClient {
66476654
console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));
66486655
} catch (error) {
66496656
console.error('Error initializing schemas:', error);
6657+
this.schemasCompiled = false;
6658+
if (error instanceof Error) {
6659+
error.message = \`Schema compilation failed: \${error.message}\`;
6660+
throw error;
6661+
} else {
6662+
throw new Error(\`Schema compilation failed: \${String(error)}\`);
6663+
}
66506664
}
66516665
}
66526666
@@ -6981,6 +6995,13 @@ class PostmanEchoWebSocketClientClient {
69816995
console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));
69826996
} catch (error) {
69836997
console.error('Error initializing schemas:', error);
6998+
this.schemasCompiled = false;
6999+
if (error instanceof Error) {
7000+
error.message = \`Schema compilation failed: \${error.message}\`;
7001+
throw error;
7002+
} else {
7003+
throw new Error(\`Schema compilation failed: \${String(error)}\`);
7004+
}
69847005
}
69857006
}
69867007

0 commit comments

Comments
 (0)