mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 09:59:48 -05:00
Send Error Object on SendError (#304)
This change ensures that when calling `requestContext.SendError` you are only able to supply parameters that match the language service beta protocol expected Error object. In other words, you have to provide an error message and optionally and error code. # **BREAKING API CHANGES** This will break displaying errors in Microsoft/vscode-mssql. I will be making changes to properly handle the error object shortly. * Adding contract for returning Error objects as per LanguageService "protocol" * Fixes throughout codebase to send only error message in error cases Cleanup of CredentialServiceTest unit test class Adding standard error handling for event flow validator * Adding optional data field as per protocol spec https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md * Adding optional validation for error objects
This commit is contained in:
@@ -162,7 +162,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
await requestContext.SendResult(new ExecuteRequestResult());
|
||||
return true;
|
||||
};
|
||||
Func<string, Task> queryCreateFailureAction = requestContext.SendError;
|
||||
Func<string, Task> queryCreateFailureAction = message => requestContext.SendError(message);
|
||||
|
||||
// Use the internal handler to launch the query
|
||||
return InterServiceExecuteQuery(executeParams, requestContext, queryCreateSuccessAction, queryCreateFailureAction, null, null);
|
||||
@@ -228,7 +228,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
{
|
||||
// Setup action for success and failure
|
||||
Func<Task> successAction = () => requestContext.SendResult(new QueryDisposeResult());
|
||||
Func<string, Task> failureAction = requestContext.SendError;
|
||||
Func<string, Task> failureAction = message => requestContext.SendError(message);
|
||||
|
||||
// Use the inter-service dispose functionality
|
||||
await InterServiceDisposeQuery(disposeParams.OwnerUri, successAction, failureAction);
|
||||
@@ -559,10 +559,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
Query query;
|
||||
if (!ActiveQueries.TryGetValue(saveParams.OwnerUri, out query))
|
||||
{
|
||||
await requestContext.SendError(new SaveResultRequestError
|
||||
{
|
||||
message = SR.QueryServiceQueryInvalidOwnerUri
|
||||
});
|
||||
await requestContext.SendError(SR.QueryServiceQueryInvalidOwnerUri);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -574,7 +571,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
ResultSet.SaveAsFailureAsyncEventHandler errorHandler = async (parameters, reason) =>
|
||||
{
|
||||
string message = SR.QueryServiceSaveAsFail(Path.GetFileName(parameters.FilePath), reason);
|
||||
await requestContext.SendError(new SaveResultRequestError { message = message });
|
||||
await requestContext.SendError(message);
|
||||
};
|
||||
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user