# Class RpcException (2.66.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.66.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.RpcException)
- [2.63.0](https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/2.63.0/Grpc.Core.RpcException)
- [2.48.0](https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/2.48.0/Grpc.Core.RpcException)

    public class RpcException : Exception, ISerializable

Thrown when remote procedure call fails. Every `RpcException` is associated with a resulting [Status](https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.RpcException#Grpc_Core_RpcException_Status) of the call.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> [Exception](https://learn.microsoft.com/dotnet/api/system.exception) \> RpcException

## Implements

[ISerializable](https://learn.microsoft.com/dotnet/api/system.runtime.serialization.iserializable)

## Inherited Members

[Exception.GetBaseException()](https://learn.microsoft.com/dotnet/api/system.exception.getbaseexception) [Exception.GetObjectData(SerializationInfo, StreamingContext)](https://learn.microsoft.com/dotnet/api/system.exception.getobjectdata) [Exception.GetType()](https://learn.microsoft.com/dotnet/api/system.exception.gettype) [Exception.ToString()](https://learn.microsoft.com/dotnet/api/system.exception.tostring) [Exception.Data](https://learn.microsoft.com/dotnet/api/system.exception.data) [Exception.HelpLink](https://learn.microsoft.com/dotnet/api/system.exception.helplink) [Exception.HResult](https://learn.microsoft.com/dotnet/api/system.exception.hresult) [Exception.InnerException](https://learn.microsoft.com/dotnet/api/system.exception.innerexception) [Exception.Message](https://learn.microsoft.com/dotnet/api/system.exception.message) [Exception.Source](https://learn.microsoft.com/dotnet/api/system.exception.source) [Exception.StackTrace](https://learn.microsoft.com/dotnet/api/system.exception.stacktrace) [Exception.TargetSite](https://learn.microsoft.com/dotnet/api/system.exception.targetsite) [Exception.SerializeObjectState](https://learn.microsoft.com/dotnet/api/system.exception.serializeobjectstate) [object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals)

## Namespace

[Grpc.Core](https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core)

## Assembly

Grpc.Core.Api.dll

## Constructors

### RpcException(Status)

    public RpcException(Status status)

Creates a new `RpcException` associated with given status.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `status` | `https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Status` Resulting status of a call. |

### RpcException(Status, Metadata)

    public RpcException(Status status, Metadata trailers)

Creates a new `RpcException` associated with given status and trailing response metadata.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `status` | `https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Status` Resulting status of a call. |
| `trailers` | `https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Metadata` Response trailing metadata. |

### RpcException(Status, Metadata, string)

    public RpcException(Status status, Metadata trailers, string message)

Creates a new `RpcException` associated with given status, message and trailing response metadata.
NOTE: the exception message is not sent to the remote peer. Use `status.Details` to pass error
details to the peer.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `status` | `https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Status` Resulting status of a call. |
| `trailers` | `https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Metadata` Response trailing metadata. |
| `message` | `https://learn.microsoft.com/dotnet/api/system.string` The exception message. |

### RpcException(Status, string)

    public RpcException(Status status, string message)

Creates a new `RpcException` associated with given status and message.
NOTE: the exception message is not sent to the remote peer. Use `status.Details` to pass error
details to the peer.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `status` | `https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Status` Resulting status of a call. |
| `message` | `https://learn.microsoft.com/dotnet/api/system.string` The exception message. |

## Properties

### Status

    public Status Status { get; }

Resulting status of the call.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Status` |   |

### StatusCode

    public StatusCode StatusCode { get; }

Returns the status code of the call, as a convenient alternative to [Status.StatusCode](https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.RpcException#Grpc_Core_RpcException_StatusCode).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.StatusCode` |   |

### Trailers

    public Metadata Trailers { get; }

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 `RpcException` thrown by the server-side part of the stack will have trailers always set to empty.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Metadata` |   |