Socket
Book a DemoInstallSign in
Socket

@purinton/errors

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@purinton/errors

A generic handler for catching uncaught errors, warnings, and rejections.

1.0.15
latest
Source
npmnpm
Version published
Weekly downloads
41
86.36%
Maintainers
1
Weekly downloads
 
Created
Source

Purinton Dev

@purinton/errors npm versionlicensebuild status

Minimal Node.js process-level error handler utility for uncaught exceptions, unhandled rejections, and warnings. Works in both CommonJS and ESM environments.

Table of Contents

Features

  • Handles uncaught exceptions, unhandled rejections, and warnings
  • Pluggable logger (defaults to @purinton/log)
  • Easy to add/remove handlers for testability
  • Works in both CommonJS and ESM modules

Installation

npm install @purinton/errors

Usage

ESM Example

import { registerHandlers } from '@purinton/errors';
registerHandlers();

// Or with options:
// registerHandlers({ processObj: process, log: customLogger });

// Simulate an uncaught exception
setTimeout(() => { throw new Error('Demo uncaught exception'); }, 1000);

CommonJS Example

const { registerHandlers } = require('@purinton/errors');
registerHandlers();

// Or with options:
// registerHandlers({ processObj: process, log: customLogger });

// Simulate an uncaught exception
setTimeout(() => { throw new Error('Demo uncaught exception'); }, 1000);

API

registerHandlers(options)

Registers process-level exception handlers. Returns an object with a removeHandlers function to detach all handlers (useful for testing).

  • options (optional): An object with the following properties:
    • processObj (optional): The process object to attach handlers to (default: process)
    • log (optional): Logger for output (default: @purinton/log)
  • Returns: { removeHandlers: () => void }

TypeScript

Type definitions are included:

export declare function registerHandlers(
  options?: {
    processObj?: NodeJS.Process,
    log?: typeof import('@purinton/log')
  }
): { removeHandlers: () => void };

Support

For help, questions, or to chat with the author and community, visit:

DiscordPurinton Dev

Purinton Dev on Discord

License

MIT © 2025 Russell Purinton

Keywords

nodejs

FAQs

Package last updated on 11 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.