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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@nivinjoseph/n-exception

v2.0.2

Published

Library of Exception classes

Downloads

4,753

Readme

n-exception

A TypeScript library providing a comprehensive set of exception classes for robust error handling in applications.

Overview

n-exception is a TypeScript library that extends the standard JavaScript Error class to provide a more structured and type-safe way of handling exceptions in your applications. It includes a base Exception class and several specialized exception types for common error scenarios.

Installation

npm install @nivinjoseph/n-exception
# or
yarn add @nivinjoseph/n-exception

Features

  • Base Exception class extending JavaScript's Error
  • Support for inner exceptions (error chaining)
  • Type-safe exception handling
  • Comprehensive stack trace support
  • Common exception types for various scenarios

Available Exception Types

  • Exception - Base exception class
  • ApplicationException - For application-level errors
  • ArgumentException - For invalid argument errors
  • ArgumentNullException - For null argument errors
  • InvalidArgumentException - For invalid argument values
  • InvalidOperationException - For invalid operation attempts
  • NotImplementedException - For unimplemented functionality
  • ObjectDisposedException - For attempts to use disposed objects

Usage

Basic Usage

import { Exception, ArgumentNullException } from "@nivinjoseph/n-exception";

// Creating a basic exception
const ex = new Exception("Something went wrong");

// Creating an exception with an inner exception
const innerEx = new Error("Original error");
const exWithInner = new Exception("Operation failed", innerEx);

// Using specialized exceptions
function processUser(user: any) {
    if (!user) {
        throw new ArgumentNullException("user");
    }
    // ... rest of the function
}

Error Chaining

try {
    // Some operation that might fail
} catch (error) {
    throw new ApplicationException("Failed to process data", error);
}

Custom Exceptions

You can create your own exception types by extending the base Exception class:

class CustomException extends Exception {
    constructor(message: string, innerException?: Error) {
        super(message, innerException);
    }
}

API Reference

Exception Class

The base Exception class provides the following properties and methods:

  • name: The name of the exception type
  • message: The error message
  • innerException: The inner exception (if any)
  • stack: The stack trace

License

This project is licensed under the MIT License - see the LICENSE file for details.