Kind: Class
Source: packages/common/exceptions/internal-server-error.exception.ts
Part of: 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
mermaidgraph 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
tsimport { 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
InternalServerErrorExceptiononly for unexpected server-side failures that should produce an HTTP500response. - Prefer more specific exceptions, such as
BadRequestExceptionorNotFoundException, 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:49DisconnectedClientController—integration/microservices/src/disconnected.controller.ts:12ExpressAdapter—packages/platform-express/adapters/express-adapter.ts:51
Was this page helpful?