Skip to content

DescriptionAndOptions

reference
1 min readUpdated

Kind: Interface

Source: packages/common/exceptions/http.exception.ts

Part of: Common

DescriptionAndOptions groups a human-readable exception description with the HttpExceptionOptions used to configure how an HTTP exception is created or handled. It is typically used internally when normalizing exception constructor arguments into a consistent structure.

Properties

PropertyType
descriptionstring
httpExceptionOptionsHttpExceptionOptions

Diagram

mermaid
graph LR
  A[Exception input] --> B[DescriptionAndOptions]
  B --> C[description: string]
  B --> D[httpExceptionOptions: HttpExceptionOptions]
  D --> E[HTTP exception configuration]

Usage

ts
import type { HttpExceptionOptions } from './http.exception';

interface DescriptionAndOptions {
  description: string;
  httpExceptionOptions: HttpExceptionOptions;
}

const exceptionDetails: DescriptionAndOptions = {
  description: 'The requested user could not be found.',
  httpExceptionOptions: {
    cause: new Error('User lookup returned no result'),
  },
};

// Use the normalized values when constructing an HTTP exception.
const { description, httpExceptionOptions } = exceptionDetails;

AI Coding Instructions

  • Keep description as a clear, client-safe string explaining the exception condition.
  • Pass exception metadata through httpExceptionOptions rather than adding unrelated fields to this interface.
  • Preserve the cause option when wrapping lower-level errors so error chains remain traceable.
  • Use this shape when normalizing overloaded HTTP exception constructor inputs into a single internal representation.

Was this page helpful?

Download as PDF
DescriptionAndOptions — NestJS head-to-head