# HttpExceptionBody

**Kind:** Interface

**Source:** [`packages/common/interfaces/http/http-exception-body.interface.ts`](https://github.com/nestjs/nest/blob/master/packages/common/interfaces/http/http-exception-body.interface.ts#L3)

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

`HttpExceptionBody` defines the standardized payload returned for HTTP exceptions. It combines a human-readable `message`, an error category string, and the numeric HTTP `statusCode` so clients can reliably inspect failed responses.

## Properties

| Property | Type |
|---|---|
| `message` | `HttpExceptionBodyMessage` |
| `error` | `string` |
| `statusCode` | `number` |

## Diagram

```mermaid
graph LR
  A[HTTP Exception] --> B[HttpExceptionBody]
  B --> C[message: HttpExceptionBodyMessage]
  B --> D[error: string]
  B --> E[statusCode: number]
  C --> F[Client-facing error details]
  D --> G[Error category]
  E --> H[HTTP status code]
```

## Usage

```ts
import type { HttpExceptionBody } from './http-exception-body.interface';

const responseBody: HttpExceptionBody = {
  message: ['Email must be valid', 'Password must contain 8 characters'],
  error: 'Bad Request',
  statusCode: 400,
};

function handleError(body: HttpExceptionBody) {
  console.error(`${body.statusCode} ${body.error}`, body.message);
}

handleError(responseBody);
```

## AI Coding Instructions

- Preserve the `message`, `error`, and `statusCode` fields when constructing standardized HTTP error responses.
- Treat `message` as `HttpExceptionBodyMessage`; it may represent a single message or multiple validation messages.
- Use valid HTTP status codes for `statusCode` and keep `error` aligned with the corresponding error category.
- Prefer this interface for serialized exception response bodies rather than exposing internal error objects or stack traces.
