Skip to content

NotImplementedException

reference
1 min readUpdated

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

mermaid
graph 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

ts
import { 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 NotImplementedException only 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 NotFoundException when an entity does not exist.
  • Do not use it for invalid client input; use validation or BadRequestException for 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?

Download as PDF
NotImplementedException — NestJS head-to-head