Kind: Class
Source: packages/common/exceptions/not-implemented.exception.ts
Part of: Common
Defines an HTTP exception for Not Implemented type errors.
NotImplementedException represents an HTTP 501 Not Implemented error. Use it when an endpoint, feature, or operation is recognized by the application but is not currently supported or available.
Extends: HttpException
Diagram
mermaidgraph LR A[Client Request] --> B[Controller or Service] B --> C{Feature Implemented?} C -- No --> D[Throw NotImplementedException] D --> E[HTTP 501 Response] C -- Yes --> F[Continue Processing]
Usage
tsimport { NotImplementedException } from '@nestjs/common';
export class ReportsService {
exportReport(format: string) {
if (format === 'xml') {
throw new NotImplementedException(
'XML report exports are not implemented yet.',
);
}
return this.generateSupportedReport(format);
}
private generateSupportedReport(format: string) {
return { format, status: 'generated' };
}
}
AI Coding Instructions
- Throw
NotImplementedExceptiononly for recognized functionality that is intentionally unavailable, resulting in an HTTP 501 response. - Prefer a clear, user-facing message that identifies the unsupported feature or operation.
- Do not use this exception for missing resources; use
NotFoundExceptionwhen an entity does not exist. - Do not use it for invalid client input; use validation or
BadRequestExceptionfor unsupported request values. - Let framework exception handling serialize the exception into the standard HTTP error response rather than manually constructing a response.
Was this page helpful?