diff --git a/src/csharp/Grpc.Core.Api/Status.cs b/src/csharp/Grpc.Core.Api/Status.cs index 32f79f74cc1..c13f9d88133 100644 --- a/src/csharp/Grpc.Core.Api/Status.cs +++ b/src/csharp/Grpc.Core.Api/Status.cs @@ -46,15 +46,16 @@ namespace Grpc.Core /// Creates a new instance of Status. /// Users should not use this constructor, except for creating instances for testing. /// The debug error string should only be populated by gRPC internals. + /// Note: experimental API that can change or be removed without any prior notice. /// /// Status code. /// Detail. - /// Optional internal error details. - public Status(StatusCode statusCode, string detail, Exception debugErrorException) + /// Optional internal error details. + public Status(StatusCode statusCode, string detail, Exception debugException) { StatusCode = statusCode; Detail = detail; - DebugErrorException = debugErrorException; + DebugException = debugException; } /// @@ -75,17 +76,18 @@ namespace Grpc.Core /// never rely on values of this field (it should use StatusCode and Detail instead). /// Example: when a client fails to connect to a server, this field may provide additional details /// why the connection to the server has failed. + /// Note: experimental API that can change or be removed without any prior notice. /// - public Exception DebugErrorException { get; } + public Exception DebugException { get; } /// /// Returns a that represents the current . /// public override string ToString() { - if (DebugErrorException != null) + if (DebugException != null) { - return $"Status(StatusCode=\"{StatusCode}\", Detail=\"{Detail}\", DebugErrorException=\"{DebugErrorException}\")"; + return $"Status(StatusCode=\"{StatusCode}\", Detail=\"{Detail}\", DebugException=\"{DebugException}\")"; } return $"Status(StatusCode=\"{StatusCode}\", Detail=\"{Detail}\")"; } diff --git a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs index 7072851732a..7ff639c7ca9 100644 --- a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs +++ b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs @@ -144,18 +144,18 @@ namespace Grpc.Core.Tests { helper.UnaryHandler = new UnaryServerMethod((request, context) => { - context.Status = new Status(StatusCode.Unauthenticated, "", new DebugErrorException("this DebugErrorString value should not be transmitted to the client")); + context.Status = new Status(StatusCode.Unauthenticated, "", new CoreErrorDetailException("this DebugErrorString value should not be transmitted to the client")); return Task.FromResult(""); }); var ex = Assert.Throws(() => Calls.BlockingUnaryCall(helper.CreateUnaryCall(), "abc")); Assert.AreEqual(StatusCode.Unauthenticated, ex.Status.StatusCode); - StringAssert.Contains("Error received from peer", ex.Status.DebugErrorException.Message, "Is \"Error received from peer\" still a valid substring to search for in the client-generated error message from C-core?"); + StringAssert.Contains("Error received from peer", ex.Status.DebugException.Message, "Is \"Error received from peer\" still a valid substring to search for in the client-generated error message from C-core?"); Assert.AreEqual(0, ex.Trailers.Count); var ex2 = Assert.ThrowsAsync(async () => await Calls.AsyncUnaryCall(helper.CreateUnaryCall(), "abc")); Assert.AreEqual(StatusCode.Unauthenticated, ex2.Status.StatusCode); - StringAssert.Contains("Error received from peer", ex2.Status.DebugErrorException.Message, "Is \"Error received from peer\" still a valid substring to search for in the client-generated error message from C-core?"); + StringAssert.Contains("Error received from peer", ex2.Status.DebugException.Message, "Is \"Error received from peer\" still a valid substring to search for in the client-generated error message from C-core?"); Assert.AreEqual(0, ex2.Trailers.Count); } diff --git a/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs b/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs index e00f153c21f..025f93e86c8 100644 --- a/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs @@ -93,7 +93,7 @@ namespace Grpc.Core.Internal IntPtr detailsPtr = Native.grpcsharp_batch_context_recv_status_on_client_details(this, out detailsLength); string details = MarshalUtils.PtrToStringUTF8(detailsPtr, (int)detailsLength.ToUInt32()); string debugErrorString = Marshal.PtrToStringAnsi(Native.grpcsharp_batch_context_recv_status_on_client_error_string(this)); - var status = new Status(Native.grpcsharp_batch_context_recv_status_on_client_status(this), details, debugErrorString != null ? new DebugErrorException(debugErrorString) : null); + var status = new Status(Native.grpcsharp_batch_context_recv_status_on_client_status(this), details, debugErrorString != null ? new CoreErrorDetailException(debugErrorString) : null); IntPtr metadataArrayPtr = Native.grpcsharp_batch_context_recv_status_on_client_trailing_metadata(this); var metadata = MetadataArraySafeHandle.ReadMetadataFromPtrUnsafe(metadataArrayPtr); diff --git a/src/csharp/Grpc.Core/Internal/DebugErrorException.cs b/src/csharp/Grpc.Core/Internal/CoreErrorDetailException.cs similarity index 87% rename from src/csharp/Grpc.Core/Internal/DebugErrorException.cs rename to src/csharp/Grpc.Core/Internal/CoreErrorDetailException.cs index a8c4561c4bf..ca688648138 100644 --- a/src/csharp/Grpc.Core/Internal/DebugErrorException.cs +++ b/src/csharp/Grpc.Core/Internal/CoreErrorDetailException.cs @@ -26,9 +26,9 @@ namespace Grpc.Core.Internal /// /// Represents error details provides by C-core's debug_error_string /// - internal class DebugErrorException : Exception + internal class CoreErrorDetailException : Exception { - public DebugErrorException(string message) : base(message) + public CoreErrorDetailException(string message) : base(message) { } }