mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Stops OE from breaking when paused DBs are expanded (#2083)
* Send session failed notification for paused DBs * Creates error node when connections fail * Revert "Send session failed notification for paused DBs" This reverts commit 1f09d8adf9aadb61a7644f84f40558710b0ba5f2. * Adjusts error node label * Code clean up * Update src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerService.cs Co-authored-by: Charles Gagnon <chgagnon@microsoft.com> * Cleans up error node info creation * Rename create error node method --------- Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>
This commit is contained in:
@@ -78,6 +78,31 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts
|
||||
public NodeFilterProperty[] FilterableProperties { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a NodeInfo and configures it for error situations
|
||||
/// </summary>
|
||||
public static class ErrorNodeInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper function to create an error node.
|
||||
/// </summary>
|
||||
/// <param name="parentNodePath">The parent node the error node will appear under</param>
|
||||
/// <param name="errorMessage">The error message to display in the error node</param>
|
||||
/// <returns>NodeInfo instance with the specified parent path and error message</returns>
|
||||
public static NodeInfo Create(string parentNodePath, string errorMessage)
|
||||
{
|
||||
return new NodeInfo()
|
||||
{
|
||||
ParentNodePath = parentNodePath,
|
||||
ErrorMessage = errorMessage,
|
||||
Label = errorMessage,
|
||||
ObjectType = "error",
|
||||
NodeType = "error",
|
||||
IsLeaf = true
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The filterable properties that a node supports
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
@@ -453,7 +453,18 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
||||
else
|
||||
{
|
||||
Logger.Verbose($"Expanding {nodePath}");
|
||||
nodes = node.Expand(cancelToken, securityToken?.Token, filters).Select(x => x.ToNodeInfo()).ToArray();
|
||||
try
|
||||
{
|
||||
nodes = node.Expand(cancelToken, securityToken?.Token, filters).Select(x => x.ToNodeInfo()).ToArray();
|
||||
}
|
||||
catch (ConnectionFailureException ex)
|
||||
{
|
||||
var errorMessage = ex.InnerException?.Message ?? ex.Message;
|
||||
|
||||
Logger.Error($"Failed to expand node: {errorMessage}");
|
||||
var errorNode = ErrorNodeInfo.Create(parentNodePath: nodePath, errorMessage: errorMessage);
|
||||
nodes = new NodeInfo[] { errorNode };
|
||||
}
|
||||
}
|
||||
response.Nodes = nodes;
|
||||
response.ErrorMessage = node.ErrorMessage;
|
||||
|
||||
Reference in New Issue
Block a user