mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-17 02:51:45 -05:00
Catch parser errors to prevent crashing (#617)
This commit is contained in:
@@ -765,13 +765,21 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
// parse on separate thread so stack size can be increased
|
// parse on separate thread so stack size can be increased
|
||||||
var parseThread = new Thread(() =>
|
var parseThread = new Thread(() =>
|
||||||
{
|
{
|
||||||
// parse current SQL file contents to retrieve a list of errors
|
try
|
||||||
ParseResult parseResult = Parser.IncrementalParse(
|
{
|
||||||
scriptFile.Contents,
|
// parse current SQL file contents to retrieve a list of errors
|
||||||
parseInfo.ParseResult,
|
ParseResult parseResult = Parser.IncrementalParse(
|
||||||
this.DefaultParseOptions);
|
scriptFile.Contents,
|
||||||
|
parseInfo.ParseResult,
|
||||||
|
this.DefaultParseOptions);
|
||||||
|
|
||||||
parseInfo.ParseResult = parseResult;
|
parseInfo.ParseResult = parseResult;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// Log the exception but don't rethrow it to prevent parsing errors from crashing SQL Tools Service
|
||||||
|
Logger.Write(LogLevel.Error, string.Format("An unexpected error occured while parsing: {0}", e.ToString()));
|
||||||
|
}
|
||||||
}, ConnectedBindingQueue.QueueThreadStackSize);
|
}, ConnectedBindingQueue.QueueThreadStackSize);
|
||||||
parseThread.Start();
|
parseThread.Start();
|
||||||
parseThread.Join();
|
parseThread.Join();
|
||||||
|
|||||||
Reference in New Issue
Block a user