mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-29 09:35:38 -05:00
Throw exception on connection failure to be captured by frontend (#2190)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user