🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@leonardoraele/err

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@leonardoraele/err

A simple error class with support for adding context data

latest
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

Err

NPM Version

Install

npm install @leonardoraele/err

Usage

import { Err } from '@leonardoraele/err';
new Err('This is an error')
	.with({ context: 'Add JSON data this way' }) // Use `.with()` to add content information tot he error
	.causes('Another error')                     // Use `.causes()` to create a new error that has `this` error as a
	                                             //   cause. When the new error is stringified (e.g. in the console),
												 //   the cause will be displayed in a separated.
	.throw();                                    // Use `throw()` to throw the error in an expression instead of
	                                             //   requiring a dedicated statement.

Output in Node 23:

Uncaught:
Err [Error]: Another error
    at ... {
  details: undefined,
  [cause]: Err [Error]: This is an error
      at ... {
    details: { context: 'Add JSON data this way' }
  }
}

Keywords

error

FAQs

Package last updated on 12 Aug 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