Skip to content

Commit c7e31f7

Browse files
committed
Added handling for instance when failure to expand node
1 parent b208a3b commit c7e31f7

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/constants/locConstants.ts

+6
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,12 @@ export function enableRichExperiencesPrompt(learnMoreUrl: string) {
680680
}
681681
export let enableRichExperiences = l10n.t("Enable Experiences & Reload");
682682

683+
export class ObjectExplorer {
684+
public static ErrorLoadingRefreshToTryAgain = l10n.t(
685+
"Error loading; refresh to try again",
686+
);
687+
}
688+
683689
export class ConnectionDialog {
684690
public static connectionDialog = l10n.t("Connection Dialog (Preview)");
685691
public static azureAccount = l10n.t("Azure Account");

src/objectExplorer/objectExplorerService.ts

+40-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,12 @@ export class ObjectExplorerService {
360360
private handleExpandSessionNotification(): NotificationHandler<ExpandResponse> {
361361
const self = this;
362362
const handler = (result: ExpandResponse) => {
363-
if (result && result.nodes) {
363+
if (!result) {
364+
return undefined;
365+
}
366+
367+
if (result.nodes && !result.errorMessage) {
368+
// successfully received children from SQL Tools Service
364369
const credentials =
365370
self._sessionIdToConnectionCredentialsMap.get(
366371
result.sessionId,
@@ -402,6 +407,40 @@ export class ObjectExplorerService {
402407
return;
403408
}
404409
}
410+
} else {
411+
// failure to expand node; display error
412+
413+
if (result.errorMessage) {
414+
self._connectionManager.vscodeWrapper.showErrorMessage(
415+
result.errorMessage,
416+
);
417+
}
418+
419+
const expandParams: ExpandParams = {
420+
sessionId: result.sessionId,
421+
nodePath: result.nodePath,
422+
};
423+
const parentNode = self.getParentFromExpandParams(expandParams);
424+
425+
const errorNode = new vscode.TreeItem(
426+
LocalizedConstants.ObjectExplorer.ErrorLoadingRefreshToTryAgain,
427+
TreeItemCollapsibleState.None,
428+
);
429+
430+
self._treeNodeToChildrenMap.set(parentNode, [errorNode]);
431+
432+
for (let key of self._expandParamsToPromiseMap.keys()) {
433+
if (
434+
key.sessionId === expandParams.sessionId &&
435+
key.nodePath === expandParams.nodePath
436+
) {
437+
let promise = self._expandParamsToPromiseMap.get(key);
438+
promise.resolve([errorNode as TreeNodeInfo]);
439+
self._expandParamsToPromiseMap.delete(key);
440+
self._expandParamsToTreeNodeInfoMap.delete(key);
441+
return;
442+
}
443+
}
405444
}
406445
};
407446
return handler;

0 commit comments

Comments
 (0)