Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
[VS Code] Fix add cluster bug when connection timeout (#3929)
Browse files Browse the repository at this point in the history
* add try catch to json parse error message

* add some description for cluster config
  • Loading branch information
yiyione authored Dec 2, 2019
1 parent c5ac48e commit 3102160
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions schemas/pai_cluster.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
},
"password": {
"type": "string",
"description": "PAI cluster password",
"description": "PAI cluster password, please keep it empty if use token",
"minLength": 1
},
"token": {
"type": "string",
"description": "PAI cluster access token",
"description": "PAI cluster access token, please keep it empty if use password",
"minLength": 1
},
"rest_server_uri": {
Expand Down
12 changes: 8 additions & 4 deletions src/pai/clusterManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,14 @@ export class ClusterManager extends Singleton {
}));
cluster.protocol_version = '2';
} catch (exception) {
const error: any = JSON.parse(exception.error);
if (error.code === 'NoApiError') {
cluster.protocol_version = '1';
} else {
try {
const error: any = JSON.parse(exception.error);
if (error.code === 'NoApiError') {
cluster.protocol_version = '1';
} else {
cluster.protocol_version = '2';
}
} catch (err) {
cluster.protocol_version = '2';
}
}
Expand Down

0 comments on commit 3102160

Please sign in to comment.