Throw exception on connection failure to be captured by frontend (#2190)

This commit is contained in:
Cheena Malhotra
2023-08-23 18:28:47 -07:00
committed by GitHub
parent 2502e23f43
commit 4e5a7ebe97
7 changed files with 182 additions and 177 deletions

View File

@@ -158,29 +158,12 @@ namespace Microsoft.SqlTools.Hosting.Protocol
}
catch (Exception ex)
{
Logger.Error($"{requestType.MethodName} : {GetErrorMessage(ex, true)}");
await requestContext.SendError(GetErrorMessage(ex));
Logger.Error($"{requestType.MethodName} : {ex.GetFullErrorMessage(true)}");
await requestContext.SendError(ex.GetFullErrorMessage());
}
});
}
private string GetErrorMessage(Exception e, bool includeStackTrace = false)
{
List<string> errors = new List<string>();
while (e != null)
{
errors.Add(e.Message);
if (includeStackTrace)
{
errors.Add(e.StackTrace);
}
e = e.InnerException;
}
return errors.Count > 0 ? string.Join(includeStackTrace ? Environment.NewLine : " ---> ", errors) : string.Empty;
}
public void SetEventHandler<TParams>(
EventType<TParams> eventType,
Func<TParams, EventContext, Task> eventHandler)