# InternalServerErrorException

**Kind:** Class

**Source:** [`packages/common/exceptions/internal-server-error.exception.ts`](https://github.com/nestjs/nest/blob/master/packages/common/exceptions/internal-server-error.exception.ts#L11)

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

Defines an HTTP exception for *Internal Server Error* type errors.

`InternalServerErrorException` represents an HTTP 500 error for unexpected server-side failures. It extends NestJS's HTTP exception system, producing a standardized error response that can be handled by Nest's built-in exception filters. Use it when a request cannot be completed because of an internal application or infrastructure error.

**Extends:** `HttpException`

## Diagram

```mermaid
graph LR
  A[Controller or Service] --> B[Unexpected server-side failure]
  B --> C[InternalServerErrorException]
  C --> D[HttpException base class]
  D --> E[HTTP 500 Internal Server Error response]
```

## Usage

```ts
import { InternalServerErrorException } from '@nestjs/common';

async function createReport(): Promise<{ id: string }> {
  try {
    // Perform an operation that may fail unexpectedly.
    return await reportService.generate();
  } catch (error) {
    throw new InternalServerErrorException(
      'Unable to generate the report. Please try again later.',
    );
  }
}
```

## AI Coding Instructions

- Throw `InternalServerErrorException` only for unexpected server-side failures that should produce an HTTP `500` response.
- Prefer more specific exceptions, such as `BadRequestException` or `NotFoundException`, when the failure is caused by invalid client input or missing resources.
- Do not expose sensitive implementation details, stack traces, credentials, or raw database errors in the exception message.
- Allow NestJS exception filters to serialize this exception into the standard HTTP error response format.
- Preserve the original error in logs or observability tooling before throwing a sanitized exception response.

## Used by

3 references from 3 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Imported by (3)

- `RouteDefinition` — `packages/core/router/router-explorer.ts`:49
- `DisconnectedClientController` — `integration/microservices/src/disconnected.controller.ts`:12
- `ExpressAdapter` — `packages/platform-express/adapters/express-adapter.ts`:51
