Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve stack trace DocumentClientException to ResponseMessage #921

Merged
merged 10 commits into from
Nov 21, 2019
Merged
21 changes: 1 addition & 20 deletions Microsoft.Azure.Cosmos/src/Util/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ namespace Microsoft.Azure.Cosmos

internal static class Extensions
{
private static readonly char[] NewLineCharacters = new[] { '\r', '\n' };

internal static ResponseMessage ToCosmosResponseMessage(this DocumentServiceResponse response, RequestMessage requestMessage)
{
Debug.Assert(requestMessage != null, nameof(requestMessage));
Expand Down Expand Up @@ -59,24 +57,7 @@ internal static ResponseMessage ToCosmosResponseMessage(this DocumentClientExcep

// if there is a status code then it came from the backend, return error as http error instead of throwing the exception
ResponseMessage cosmosResponse = new ResponseMessage(dce.StatusCode ?? HttpStatusCode.InternalServerError, request);
string reasonPhraseString = string.Empty;
if (!string.IsNullOrEmpty(dce.Message))
{
if (dce.Message.IndexOfAny(Extensions.NewLineCharacters) >= 0)
{
StringBuilder sb = new StringBuilder(dce.Message);
sb = sb.Replace("\r", string.Empty);
sb = sb.Replace("\n", string.Empty);
reasonPhraseString = sb.ToString();
}
else
{
reasonPhraseString = dce.Message;
}
}

cosmosResponse.ErrorMessage = reasonPhraseString;
cosmosResponse.Error = dce.Error;
cosmosResponse.ErrorMessage = dce.ToString();
j82w marked this conversation as resolved.
Show resolved Hide resolved
kirankumarkolli marked this conversation as resolved.
Show resolved Hide resolved

if (dce.Headers != null)
{
Expand Down