Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Grpc.Core.Api/Status.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
#endregion

using System;
using System.Diagnostics;

namespace Grpc.Core;

// TODO(jtattermusch): make the Status struct readonly
/// <summary>
/// Represents RPC result, which consists of <see cref="StatusCode"/> and an optional detail string.
/// </summary>
[DebuggerDisplay("{DebuggerToString(),nq}")]
public struct Status
{
/// <summary>
Expand Down Expand Up @@ -93,4 +95,19 @@ public override string ToString()
}
return $"Status(StatusCode=\"{StatusCode}\", Detail=\"{Detail}\")";
}

private string DebuggerToString()
{
var text = $"StatusCode = {StatusCode}";
if (!string.IsNullOrEmpty(Detail))
{
text += $@", Detail = ""{Detail}""";
}
if (DebugException != null)
{
text += $@", DebugException = ""{DebugException.GetType()}: {DebugException.Message}""";
}

return text;
}
}