diff options
Diffstat (limited to 'src/csharp/Grpc.Core/RpcException.cs')
-rw-r--r-- | src/csharp/Grpc.Core/RpcException.cs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/csharp/Grpc.Core/RpcException.cs b/src/csharp/Grpc.Core/RpcException.cs index 01b9e4fb1a..d2c912e73a 100644 --- a/src/csharp/Grpc.Core/RpcException.cs +++ b/src/csharp/Grpc.Core/RpcException.cs @@ -17,6 +17,7 @@ #endregion using System; +using Grpc.Core.Utils; namespace Grpc.Core { @@ -26,6 +27,7 @@ namespace Grpc.Core public class RpcException : Exception { private readonly Status status; + private readonly Metadata trailers; /// <summary> /// Creates a new <c>RpcException</c> associated with given status. @@ -34,6 +36,7 @@ namespace Grpc.Core public RpcException(Status status) : base(status.ToString()) { this.status = status; + this.trailers = Metadata.Empty; } /// <summary> @@ -44,6 +47,18 @@ namespace Grpc.Core public RpcException(Status status, string message) : base(message) { this.status = status; + this.trailers = Metadata.Empty; + } + + /// <summary> + /// Creates a new <c>RpcException</c> associated with given status and trailing response metadata. + /// </summary> + /// <param name="status">Resulting status of a call.</param> + /// <param name="trailers">Response trailing metadata.</param> + public RpcException(Status status, Metadata trailers) : base(status.ToString()) + { + this.status = status; + this.trailers = GrpcPreconditions.CheckNotNull(trailers); } /// <summary> @@ -56,5 +71,18 @@ namespace Grpc.Core return status; } } + + /// <summary> + /// Gets the call trailing metadata. + /// Trailers only have meaningful content for client-side calls (in which case they represent the trailing metadata sent by the server when closing the call). + /// Instances of <c>RpcException</c> thrown by the server-side part of the stack will have trailers always set to empty. + /// </summary> + public Metadata Trailers + { + get + { + return trailers; + } + } } } |