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

opticore-catch-exception-error

v1.0.35

Published

opticore catch exception error

Readme

OptiCore Catch Exception Error

opticore catch exception error: logs the Node.js process events (uncaught exceptions, unhandled rejections, signals, exits, worker errors…) and handles Express errors for an OptiCore web server, with translated messages (en, fr).

Requirements

  • Node.js >= 26.12.1

Install

npm i opticore-catch-exception-error

Usage

import EventEmitter from "node:events";
import { express } from "opticore-express";
import { ServerListenEventError, CEvent } from "opticore-catch-exception-error";

const events = new ServerListenEventError("en"); // language of the logged messages: "en" or "fr"

process.on(CEvent.uncaughtException, (error) => events.uncaughtException(error));
process.on(CEvent.unhandledRejection, (reason, promise) => events.unhandledRejection(reason, promise));
process.on(CEvent.warning, (warning) => events.warning(warning));
process.on(CEvent.sigterm, (signal) => events.sigtermSignalReceived(signal));

const app = express();
const errorEmitter = new EventEmitter();
errorEmitter.on("error", () => {});

// ... your routes ...

// last middleware: Express error handler
app.use((err, req, res, next) => events.expressErrorHandlingMiddleware(errorEmitter, err, req, res, next));

The package also exports the event name constants CEvent, CEventNameError, CErrorName, CCodeError, the StackTraceError class and the error helpers AssertionErrors, InternalErrors, JavaScriptErrors, OpenSSLErrors, SystemErrors.

Security

Breaking changes

  • multipleResolves is deprecated (Node.js DEP0160). Node.js 26 no longer emits the multipleResolves process event, so a listener registered on it never runs. ServerListenEventError.multipleResolves() and CEvent.multipleResolves are kept (marked @deprecated) so existing code still compiles and still works on an older runtime.
  • expressErrorHandlingMiddleware: when the response has already started (res.headersSent), the error is handed to Express with next(err) instead of trying to send a new status.

Behaviour

  • Error listeners never throw. null, undefined, primitives, Symbols, objects with a null prototype, circular objects, BigInts and values with a throwing toString are logged safely (throw null, Promise.reject(undefined), reject(null)…). Before, a null reason crashed the listener (Cannot read properties of null (reading 'toString')) and with it the whole process.
  • An error message equal to an Object.prototype member (constructor, __proto__, toString…) is not resolved as a translation key.
  • The Express error handler never sends error details to the client. A 4xx error raised by a middleware (malformed JSON, payload too large…: err.status / err.statusCode between 400 and 499) keeps its status with the standard status text; anything else answers 500 with a fixed text (Internal Server Error / Erreur interne du serveur). The message, stack, SQL or file paths are only logged.

Warning: do not rely on multipleResolves on Node.js 26 or later: it is never emitted. Detect double resolutions in your own code (e.g. guard the resolve / reject calls) if you need them.

Warning: there is no opt-out for the fixed error text: if a client needs details, send them yourself from your route before the error reaches this handler.

Security Issues

https://github.com/guyzoum77/opticore-catch-exception-error/issues

About

OptiCore Catch Exception Error is led by Guy-serge Kouacou.