npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@origins-digital/error-utils

v1.2.0

Published

Origins Digital NestJS utils

Readme

@origins-digital/error

A comprehensive error handling package for NestJS applications that provides standardized error responses, HTTP exception handling, and Swagger documentation.

Installation

npm install @origins-digital/error

Features

  • Standardized error responses
  • HTTP exception handling
  • Automatic Swagger documentation for errors
  • Axios error handling and transformation
  • Development-friendly error details
  • Custom error filters

Usage

Basic Setup

import { Module } from '@nestjs/common';
import { APP_FILTER } from '@nestjs/core';
import { ErrorFilter } from '@origins-digital/error';

@Module({
  providers: [
    {
      provide: APP_FILTER,
      useClass: ErrorFilter,
    },
  ],
})
export class AppModule {}

Using HTTP Exceptions

import { Controller } from '@nestjs/common';
import { ApiErrors } from '@origins-digital/error';

@Controller('users')
@ApiErrors([400, 401, 403, 404, 500]) // Document common errors
export class UsersController {
  @Get(':id')
  @ApiErrors([404]) // Document specific endpoint errors
  async getUser(@Param('id') id: string) {
    // Your code here
  }
}

Handling Axios Errors

import { Injectable } from '@nestjs/common';
import { HttpService } from '@nestjs/axios';
import { raiseError } from '@origins-digital/error';

@Injectable()
export class ExternalService {
  constructor(private readonly httpService: HttpService) {}

  async fetchData() {
    try {
      const response = await this.httpService
        .get('https://api.example.com/data')
        .toPromise();
      return response.data;
    } catch (error) {
      // raiseError will format the Axios error properly for logging and error handling
      raiseError(error, { service: 'example-api' });
    }
  }

  async createResource(data: any) {
    try {
      const response = await this.httpService
        .post('https://api.example.com/resources', data)
        .toPromise();
      return response.data;
    } catch (error) {
      // The error will be properly formatted with status code and message
      raiseError(error, { service: 'example-api' });
    }
  }

  async updateResource(id: string, data: any) {
    try {
      const response = await this.httpService
        .patch(`https://api.example.com/resources/${id}`, data)
        .toPromise();
      return response.data;
    } catch (error) {
      // Error will be properly formatted for logging
      raiseError(error, { service: 'example-api' });
    }
  }
}

Error Response Format

All errors follow a standardized format:

{
  "statusCode": 404,
  "type": "NotFoundException",
  "message": "Resource not found",
  "errors": {
    // Optional: Detailed error information
  },
  "stack": "Error stack trace" // Only in development environment
}

Available HTTP Exceptions

The package includes all standard HTTP exceptions:

  • BadRequestException (400)
  • UnauthorizedException (401)
  • PaymentRequiredException (402)
  • ForbiddenException (403)
  • NotFoundException (404)
  • MethodNotAllowedException (405)
  • NotAcceptableException (406)
  • RequestTimeoutException (408)
  • ConflictException (409)
  • GoneException (410)
  • PreconditionFailedException (412)
  • PayloadTooLargeException (413)
  • UnsupportedMediaTypeException (415)
  • UnprocessableEntityException (422)
  • TooManyRequestsException (429)
  • InternalServerErrorException (500)
  • NotImplementedException (501)
  • BadGatewayException (502)
  • ServiceUnavailableException (503)
  • GatewayTimeoutException (504)
  • HttpVersionNotSupportedException (505)

Error Filter Configuration

The error filter can be configured to:

  • Include stack traces in development
  • Customize error response format
  • Handle specific error types
  • Add additional error metadata

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.