# RpcExceptionFilterMetadata

**Kind:** Interface

**Source:** [`packages/common/interfaces/exceptions/rpc-exception-filter-metadata.interface.ts`](https://github.com/nestjs/nest/blob/master/packages/common/interfaces/exceptions/rpc-exception-filter-metadata.interface.ts#L4)

**Part of:** [Common](subsystem-packages-common)

`RpcExceptionFilterMetadata` describes the runtime metadata Nest uses to connect an RPC exception filter's `catch` method with the exception classes it handles. It is typically produced during exception-filter discovery and consumed by the RPC exception handling pipeline to select an appropriate filter for a thrown error.

## Properties

| Property | Type |
|---|---|
| `func` | `RpcExceptionFilter['catch']` |
| `exceptionMetatypes` | `Type<any>[]` |

## Diagram

```mermaid
graph LR
  E[RPC handler throws exception] --> H[RPC exception handler]
  H --> M[RpcExceptionFilterMetadata]
  M --> T[exceptionMetatypes]
  M --> F[func: filter.catch]
  T -->|matches exception type| F
  F --> R[RPC error response]
```

## Usage

```ts
import { RpcException } from '@nestjs/microservices';
import type { RpcExceptionFilterMetadata } from '@nestjs/common/interfaces/exceptions/rpc-exception-filter-metadata.interface';

const rpcExceptionFilter = {
  catch(exception: RpcException) {
    return {
      status: 'error',
      message: exception.message,
    };
  },
};

const metadata: RpcExceptionFilterMetadata = {
  func: rpcExceptionFilter.catch,
  exceptionMetatypes: [RpcException],
};

// The RPC exception layer can use `exceptionMetatypes` to determine
// whether this filter should handle a thrown exception, then invoke `func`.
```

## AI Coding Instructions

- Keep `func` assigned to an exception filter's `catch` method and ensure its signature remains compatible with `RpcExceptionFilter['catch']`.
- Populate `exceptionMetatypes` with exception constructors, not instances or string names.
- Preserve the relationship between each filter callback and its handled exception types when creating or transforming metadata.
- Use this metadata in RPC exception resolution paths; do not use it as a general HTTP or WebSocket exception-filter contract.

## How it works

## `RpcExceptionFilterMetadata`

`RpcExceptionFilterMetadata` is an exported TypeScript interface for one RPC exception-filter entry. It contains a filter callback and the exception constructor types associated with that callback. [packages/common/interfaces/exceptions/rpc-exception-filter-metadata.interface.ts:4-7](packages/common/interfaces/exceptions/rpc-exception-filter-metadata.interface.ts#L4-L7)

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Imported by (1)

- `RpcExceptionsHandler` — `packages/microservices/exceptions/rpc-exceptions-handler.ts`:13
