# Class RpcExceptionExtensions (4.10.0)

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

- [4.10.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.RpcExceptionExtensions)
- [4.8.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.8.0/Google.Api.Gax.Grpc.RpcExceptionExtensions)
- [4.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.4.0/Google.Api.Gax.Grpc.RpcExceptionExtensions)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.3.1/Google.Api.Gax.Grpc.RpcExceptionExtensions)
- [4.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.2.0/Google.Api.Gax.Grpc.RpcExceptionExtensions)
- [4.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.0.0/Google.Api.Gax.Grpc.RpcExceptionExtensions)
- [3.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/3.2.0/Google.Api.Gax.Grpc.RpcExceptionExtensions)

    public static class RpcExceptionExtensions

Utility extension methods to make it easier to retrieve extended error information from an [RpcException](https://github.com/grpc/grpc-dotnet/blob/7c43ddb5d68008782dc0dba2d0feaa3ed91a9fb2/src/Grpc.Core.Api/RpcException.cs).

## Inheritance

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

## Inherited Members

[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.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

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

## Assembly

Google.Api.Gax.Grpc.dll

## Methods

### GetBadRequest(RpcException)

    public static BadRequest GetBadRequest(this RpcException ex)

Retrieves the Google.Rpc.BadRequest message containing extended error information
from the trailers in an [RpcException](https://github.com/grpc/grpc-dotnet/blob/7c43ddb5d68008782dc0dba2d0feaa3ed91a9fb2/src/Grpc.Core.Api/RpcException.cs), if present.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `ex` | `https://github.com/grpc/grpc-dotnet/blob/7c43ddb5d68008782dc0dba2d0feaa3ed91a9fb2/src/Grpc.Core.Api/RpcException.cs` The RPC exception to retrieve details from. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google.Rpc.BadRequest` | The Google.Rpc.BadRequest message specified in the exception, or null if there is no such information. |

### GetErrorInfo(RpcException)

    public static ErrorInfo GetErrorInfo(this RpcException ex)

Retrieves the Google.Rpc.ErrorInfo message containing extended error information
from the trailers in an [RpcException](https://github.com/grpc/grpc-dotnet/blob/7c43ddb5d68008782dc0dba2d0feaa3ed91a9fb2/src/Grpc.Core.Api/RpcException.cs), if present.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `ex` | `https://github.com/grpc/grpc-dotnet/blob/7c43ddb5d68008782dc0dba2d0feaa3ed91a9fb2/src/Grpc.Core.Api/RpcException.cs` The RPC exception to retrieve details from. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google.Rpc.ErrorInfo` | The Google.Rpc.ErrorInfo message specified in the exception, or null if there is no such information. |

### GetHelp(RpcException)

    public static Help GetHelp(this RpcException ex)

Retrieves the Google.Rpc.Help message containing extended error information
from the trailers in an [RpcException](https://github.com/grpc/grpc-dotnet/blob/7c43ddb5d68008782dc0dba2d0feaa3ed91a9fb2/src/Grpc.Core.Api/RpcException.cs), if present.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `ex` | `https://github.com/grpc/grpc-dotnet/blob/7c43ddb5d68008782dc0dba2d0feaa3ed91a9fb2/src/Grpc.Core.Api/RpcException.cs` The RPC exception to retrieve details from. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google.Rpc.Help` | The Google.Rpc.Help message specified in the exception, or null if there is no such information. |

### GetLocalizedMessage(RpcException)

    public static LocalizedMessage GetLocalizedMessage(this RpcException ex)

Retrieves the Google.Rpc.LocalizedMessage message containing extended error information
from the trailers in an [RpcException](https://github.com/grpc/grpc-dotnet/blob/7c43ddb5d68008782dc0dba2d0feaa3ed91a9fb2/src/Grpc.Core.Api/RpcException.cs), if present.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `ex` | `https://github.com/grpc/grpc-dotnet/blob/7c43ddb5d68008782dc0dba2d0feaa3ed91a9fb2/src/Grpc.Core.Api/RpcException.cs` The RPC exception to retrieve details from. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google.Rpc.LocalizedMessage` | The Google.Rpc.Help message specified in the exception, or null if there is no such information. |

### GetRpcStatus(RpcException)

    public static Status GetRpcStatus(this RpcException ex)

Retrieves the Google.Rpc.Status message containing extended error information
from the trailers in an [RpcException](https://github.com/grpc/grpc-dotnet/blob/7c43ddb5d68008782dc0dba2d0feaa3ed91a9fb2/src/Grpc.Core.Api/RpcException.cs), if present.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `ex` | `https://github.com/grpc/grpc-dotnet/blob/7c43ddb5d68008782dc0dba2d0feaa3ed91a9fb2/src/Grpc.Core.Api/RpcException.cs` The RPC exception to retrieve details from. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google.Rpc.Status` | The Google.Rpc.Status message specified in the exception, or null if there is no such information. |

### GetStatusDetail\<T\>(RpcException)

    public static T GetStatusDetail<T>(this RpcException ex) where T : class, IMessage<T>, new()

Retrieves the error details of type `T` from the Google.Rpc.Status
message associated with an [RpcException](https://github.com/grpc/grpc-dotnet/blob/7c43ddb5d68008782dc0dba2d0feaa3ed91a9fb2/src/Grpc.Core.Api/RpcException.cs), if any.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `ex` | `https://github.com/grpc/grpc-dotnet/blob/7c43ddb5d68008782dc0dba2d0feaa3ed91a9fb2/src/Grpc.Core.Api/RpcException.cs` The RPC exception to retrieve details from. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` |   |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` | The message type to decode from within the error details. |