Handle connection exceptions and add error callback (#126)

This commit is contained in:
Sharon Ravindran
2016-10-31 11:25:51 -07:00
committed by Karl Burtram
parent a27c182a0f
commit 6937e46c1b
3 changed files with 41 additions and 1 deletions

View File

@@ -427,8 +427,20 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
await requestContext.SendEvent(QueryExecuteCompleteEvent.Type, eventParams);
};
Query.QueryAsyncErrorEventHandler errorCallback = async errorMessage =>
{
// Send back the error message
QueryExecuteCompleteParams eventParams = new QueryExecuteCompleteParams
{
OwnerUri = executeParams.OwnerUri,
Message = errorMessage
};
await requestContext.SendEvent(QueryExecuteCompleteEvent.Type, eventParams);
};
query.QueryCompleted += callback;
query.QueryFailed += callback;
query.QueryConnectionException += errorCallback;
// Launch this as an asynchronous task
query.Execute();