提交 966bec86 编写于 作者: M Matt Bierner

Reducing scope of try catch to just exec

We want to be alerted if an exception is thrown outside of execute
上级 290af21d
......@@ -364,14 +364,14 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
]
};
let response: Proto.CompletionDetailsResponse;
let details: Proto.CompletionEntryDetails[] | undefined;
try {
response = await this.client.execute('completionEntryDetails', args, token);
const response = await this.client.execute('completionEntryDetails', args, token);
details = response.body;
} catch {
return item;
}
const details = response.body;
if (!details || !details.length || !details[0]) {
return item;
}
......
......@@ -26,18 +26,21 @@ class TypeScriptDocumentHighlightProvider implements vscode.DocumentHighlightPro
}
const args = typeConverters.Position.toFileLocationRequestArgs(file, position);
let items: Proto.OccurrencesResponseItem[] | undefined;
try {
const response = await this.client.execute('occurrences', args, token);
if (response && response.body) {
return response.body
.filter(x => !x.isInString)
.map(documentHighlightFromOccurance);
}
items = response.body;
} catch {
// noop
}
return [];
if (!items) {
return [];
}
return items
.filter(x => !x.isInString)
.map(documentHighlightFromOccurance);
}
}
......
......@@ -140,17 +140,18 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider {
await this.formattingOptionsManager.ensureConfigurationForDocument(document, undefined);
const args: Proto.GetApplicableRefactorsRequestArgs = typeConverters.Range.toFileRangeRequestArgs(file, rangeOrSelection);
let response: Proto.GetApplicableRefactorsResponse;
let refactorings: Proto.ApplicableRefactorInfo[];
try {
response = await this.client.execute('getApplicableRefactors', args, token);
if (!response || !response.body) {
const response = await this.client.execute('getApplicableRefactors', args, token);
if (!response.body) {
return undefined;
}
refactorings = response.body;
} catch {
return undefined;
}
return this.convertApplicableRefactors(response.body, document, file, rangeOrSelection);
return this.convertApplicableRefactors(refactorings, document, file, rangeOrSelection);
}
private convertApplicableRefactors(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册