include additional data for error object (#1539)

* include additional data for error

* fix tests
This commit is contained in:
Alan Ren
2022-06-10 20:40:22 -07:00
committed by GitHub
parent 5e3d24bbfa
commit 17b6073c87
14 changed files with 64 additions and 54 deletions

View File

@@ -21,9 +21,14 @@ namespace Microsoft.SqlTools.Hosting.Contracts
/// </summary>
public string Message { get; set; }
/// <summary>
/// Additional data.
/// </summary>
public string Data { get; set; }
public override string ToString()
{
return $"Error(Code={Code},Message='{Message}')";
return $"Error(Code={Code},Message='{Message}',Data='{Data}')";
}
}
}

View File

@@ -38,13 +38,14 @@ namespace Microsoft.SqlTools.Hosting.Protocol
eventParams);
}
public virtual Task SendError(string errorMessage, int errorCode = 0)
public virtual Task SendError(string errorMessage, int errorCode = 0, string data = null)
{
// Build the error message
Error error = new Error
{
Message = errorMessage,
Code = errorCode
Code = errorCode,
Data = data
};
return this.messageWriter.WriteError(
requestMessage.Method,
@@ -55,7 +56,7 @@ namespace Microsoft.SqlTools.Hosting.Protocol
public virtual Task SendError(Exception e)
{
// Overload to use the parameterized error handler
return SendError(e.Message, e.HResult);
return SendError(e.Message, e.HResult, e.StackTrace);
}
}
}