mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Throw exception on connection failure to be captured by frontend (#2190)
This commit is contained in:
@@ -66,30 +66,22 @@ namespace Microsoft.SqlTools.ServiceLayer.ServerConfigurations
|
||||
public async Task HandleServerConfigViewRequest(ServerConfigViewRequestParams parameters, RequestContext<ServerConfigViewResponseParams> requestContext)
|
||||
{
|
||||
Logger.Verbose("HandleServerConfigViewRequest");
|
||||
try
|
||||
ConnectionInfo connInfo;
|
||||
ConnectionServiceInstance.TryFindConnection(
|
||||
parameters.OwnerUri,
|
||||
out connInfo);
|
||||
if (connInfo == null)
|
||||
{
|
||||
ConnectionInfo connInfo;
|
||||
ConnectionServiceInstance.TryFindConnection(
|
||||
parameters.OwnerUri,
|
||||
out connInfo);
|
||||
if (connInfo == null)
|
||||
{
|
||||
await requestContext.SendError(new Exception(SR.ProfilerConnectionNotFound));
|
||||
}
|
||||
else
|
||||
{
|
||||
var serverConnection = ConnectionService.OpenServerConnection(connInfo);
|
||||
ServerConfigProperty serverConfig = GetConfig(serverConnection, parameters.ConfigNumber);
|
||||
await requestContext.SendResult(new ServerConfigViewResponseParams
|
||||
{
|
||||
ConfigProperty = serverConfig
|
||||
});
|
||||
}
|
||||
await requestContext.SendError(new Exception(SR.ProfilerConnectionNotFound));
|
||||
}
|
||||
catch (Exception e)
|
||||
else
|
||||
{
|
||||
// Exception related to run task will be captured here
|
||||
await requestContext.SendError(e);
|
||||
var serverConnection = ConnectionService.OpenServerConnection(connInfo);
|
||||
ServerConfigProperty serverConfig = GetConfig(serverConnection, parameters.ConfigNumber);
|
||||
await requestContext.SendResult(new ServerConfigViewResponseParams
|
||||
{
|
||||
ConfigProperty = serverConfig
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,32 +94,24 @@ namespace Microsoft.SqlTools.ServiceLayer.ServerConfigurations
|
||||
public async Task HandleServerConfigUpdateRequest(ServerConfigUpdateRequestParams parameters, RequestContext<ServerConfigUpdateResponseParams> requestContext)
|
||||
{
|
||||
Logger.Verbose("HandleServerConfigUpdateRequest");
|
||||
try
|
||||
ConnectionInfo connInfo;
|
||||
ConnectionServiceInstance.TryFindConnection(
|
||||
parameters.OwnerUri,
|
||||
out connInfo);
|
||||
ServerConfigUpdateResponseParams response = new ServerConfigUpdateResponseParams
|
||||
{
|
||||
ConnectionInfo connInfo;
|
||||
ConnectionServiceInstance.TryFindConnection(
|
||||
parameters.OwnerUri,
|
||||
out connInfo);
|
||||
ServerConfigUpdateResponseParams response = new ServerConfigUpdateResponseParams
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
if (connInfo == null)
|
||||
{
|
||||
await requestContext.SendError(new Exception(SR.ProfilerConnectionNotFound));
|
||||
}
|
||||
else
|
||||
{
|
||||
var serverConnection = ConnectionService.OpenServerConnection(connInfo);
|
||||
UpdateConfig(serverConnection, parameters.ConfigNumber, parameters.ConfigValue);
|
||||
response.ConfigProperty = GetConfig(serverConnection, parameters.ConfigNumber);
|
||||
await requestContext.SendResult(response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
if (connInfo == null)
|
||||
{
|
||||
// Exception related to run task will be captured here
|
||||
await requestContext.SendError(e);
|
||||
await requestContext.SendError(new Exception(SR.ProfilerConnectionNotFound));
|
||||
}
|
||||
else
|
||||
{
|
||||
var serverConnection = ConnectionService.OpenServerConnection(connInfo);
|
||||
UpdateConfig(serverConnection, parameters.ConfigNumber, parameters.ConfigValue);
|
||||
response.ConfigProperty = GetConfig(serverConnection, parameters.ConfigNumber);
|
||||
await requestContext.SendResult(response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,31 +123,23 @@ namespace Microsoft.SqlTools.ServiceLayer.ServerConfigurations
|
||||
public async Task HandleServerConfigListRequest(ServerConfigListRequestParams parameters, RequestContext<ServerConfigListResponseParams> requestContext)
|
||||
{
|
||||
Logger.Verbose("HandleServerConfigListRequest");
|
||||
try
|
||||
ConnectionInfo connInfo;
|
||||
ConnectionServiceInstance.TryFindConnection(
|
||||
parameters.OwnerUri,
|
||||
out connInfo);
|
||||
ServerConfigListResponseParams response = new ServerConfigListResponseParams
|
||||
{
|
||||
ConnectionInfo connInfo;
|
||||
ConnectionServiceInstance.TryFindConnection(
|
||||
parameters.OwnerUri,
|
||||
out connInfo);
|
||||
ServerConfigListResponseParams response = new ServerConfigListResponseParams
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
if (connInfo == null)
|
||||
{
|
||||
await requestContext.SendError(new Exception(SR.ProfilerConnectionNotFound));
|
||||
}
|
||||
else
|
||||
{
|
||||
var serverConnection = ConnectionService.OpenServerConnection(connInfo);
|
||||
response.ConfigProperties = GetConfigs(serverConnection);
|
||||
await requestContext.SendResult(response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
if (connInfo == null)
|
||||
{
|
||||
// Exception related to run task will be captured here
|
||||
await requestContext.SendError(e);
|
||||
await requestContext.SendError(new Exception(SR.ProfilerConnectionNotFound));
|
||||
}
|
||||
else
|
||||
{
|
||||
var serverConnection = ConnectionService.OpenServerConnection(connInfo);
|
||||
response.ConfigProperties = GetConfigs(serverConnection);
|
||||
await requestContext.SendResult(response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user