Skip to content
zedkit
@zedtech/zedkit-nest

Return uniform error bodies

A global exception filter that returns the same error body for all failures.

At a glance

  • Who: API developers who want one error shape for every failure.
  • What: A global exception filter that returns the same error body for all failures. Subclass and override toStatusBody, unknownBodyParseError, or formatBody to map domain errors without rewriting the filter.
  • Use when: As the last-resort error mapper in front of API clients.
  • Avoid when: For domain validation errors with field detail — return those from the handler instead.
  • See also: Bootstrap a Nest app, Start a safe NestJS API

Install

pnpm add @zedtech/zedkit-nest

Latest: 1.1.1 (via changesets).

Example

Usage
import { AllExceptionsFilter, type ErrorBody } from "@zedtech/zedkit-nest";
class AppFilter extends AllExceptionsFilter {
  protected override formatBody(body: ErrorBody) {
    return { code: body.code, message: body.message };
  }
}

Wraps: (none)

On this page