Skip to content

Commit 676b8be

Browse files
committed
Apply to instance: add error message when the endpoint is incorrect
1 parent 814901c commit 676b8be

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

forward_engineering/applyToInstanceHelper.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ const gremlin = require('../reverse_engineering/node_modules/gremlin');
55
const applyToInstanceHelper = _ => ({
66
setUpDocumentClient(connectionInfo) {
77
const dbNameRegExp = /wss:\/\/(\S*).gremlin\.cosmos\./i;
8-
const dbName = dbNameRegExp.exec(connectionInfo.gremlinEndpoint)[1];
9-
const endpoint = `https://${dbName}.documents.azure.com:443/`;
8+
const dbName = dbNameRegExp.exec(connectionInfo.gremlinEndpoint);
9+
if(!dbName || !dbName[1]) {
10+
throw new Error('Incorrect endpoint provided. Expected format: wss://<account name>.gremlin.cosmos.');
11+
}
12+
const endpoint = `https://${dbName[1]}.documents.azure.com:443/`;
1013
const key = connectionInfo.accountKey;
1114

1215
return new CosmosClient({ endpoint, key });

0 commit comments

Comments
 (0)