Skip to content

Commit 49889f7

Browse files
author
tomzu
committed
use try catch for JSON parser
1 parent 2564ee6 commit 49889f7

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

packages/core/src/shared/lsp/manifestResolver.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,20 @@ export class ManifestResolver {
112112
* @param manifest
113113
*/
114114
private checkDeprecation(manifest: Manifest): void {
115+
if (!manifest.isManifestDeprecated) {
116+
return
117+
}
118+
115119
const deprecationMessage = `${this.lsName} manifest is deprecated. No future updates will be available.`
116-
if (manifest.isManifestDeprecated) {
117-
logger.info(deprecationMessage)
118-
if (!this.getStorage()[this.lsName].muteDeprecation) {
119-
void vscode.window
120-
.showInformationMessage(deprecationMessage, localizedText.ok, localizedText.dontShow)
121-
.then((button) => {
122-
if (button === localizedText.dontShow) {
123-
this.getStorage()[this.lsName].muteDeprecation = true
124-
}
125-
})
126-
}
120+
logger.info(deprecationMessage)
121+
if (!this.getStorage()[this.lsName].muteDeprecation) {
122+
void vscode.window
123+
.showInformationMessage(deprecationMessage, localizedText.ok, localizedText.dontShow)
124+
.then((button) => {
125+
if (button === localizedText.dontShow) {
126+
this.getStorage()[this.lsName].muteDeprecation = true
127+
}
128+
})
127129
}
128130
}
129131

@@ -133,7 +135,7 @@ export class ManifestResolver {
133135
// Only true when incoming manifest is deprecated & existing muteDeprecation is true (set by user)
134136
const muteDeprecation =
135137
(storage[this.lsName] ? storage[this.lsName].muteDeprecation : false) &&
136-
(JSON.parse(content) as Manifest).isManifestDeprecated
138+
this.parseManifest(content).isManifestDeprecated
137139

138140
globals.globalState.tryUpdate(manifestStorageKey, {
139141
...storage,

0 commit comments

Comments
 (0)