mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
fix drop object issue and add logging (#1974)
* fix drop object issue * remove content logging * remove ununsed using.
This commit is contained in:
@@ -159,29 +159,32 @@ namespace Microsoft.SqlTools.Hosting.Protocol
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
string errorMessage = GetErrorMessage(ex);
|
Logger.Error($"{requestType.MethodName} : {GetErrorMessage(ex, true)}");
|
||||||
Logger.Error($"{requestType.MethodName} : {errorMessage}");
|
await requestContext.SendError(GetErrorMessage(ex));
|
||||||
await requestContext.SendError(errorMessage);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetErrorMessage(Exception e)
|
private string GetErrorMessage(Exception e, bool includeStackTrace = false)
|
||||||
{
|
{
|
||||||
List<string> errors = new List<string>();
|
List<string> errors = new List<string>();
|
||||||
|
|
||||||
while (e != null)
|
while (e != null)
|
||||||
{
|
{
|
||||||
errors.Add(e.Message);
|
errors.Add(e.Message);
|
||||||
|
if (includeStackTrace)
|
||||||
|
{
|
||||||
|
errors.Add(e.StackTrace);
|
||||||
|
}
|
||||||
e = e.InnerException;
|
e = e.InnerException;
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.Count > 0 ? string.Join(" ---> ", errors) : string.Empty;
|
return errors.Count > 0 ? string.Join(includeStackTrace ? Environment.NewLine : " ---> ", errors) : string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetEventHandler<TParams>(
|
public void SetEventHandler<TParams>(
|
||||||
EventType<TParams> eventType,
|
EventType<TParams> eventType,
|
||||||
Func<TParams, EventContext, Task> eventHandler)
|
Func<TParams, EventContext, Task> eventHandler)
|
||||||
{
|
{
|
||||||
this.SetEventHandler(
|
this.SetEventHandler(
|
||||||
eventType,
|
eventType,
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
}
|
}
|
||||||
catch (FailedOperationException ex)
|
catch (FailedOperationException ex)
|
||||||
{
|
{
|
||||||
if (ex.InnerException is MissingObjectException && requestParams.ThrowIfNotExist)
|
if (!(ex.InnerException is MissingObjectException) || (ex.InnerException is MissingObjectException && requestParams.ThrowIfNotExist))
|
||||||
{
|
{
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user