Awesome Open Source
Awesome Open Source

Make Error Cause

NPM version NPM downloads Build status Test coverage

Make your own nested errors.


  • Compatible with node.js and browsers
  • Works with instanceof
  • Automatic full stack traces in node.js (supports inspect())
  • Output full stack trace with fullStack(err)
  • Extends make-error


npm install make-error-cause --save


import { BaseError, fullStack } from "make-error-cause";

class CustomError extends BaseError {
  constructor(message, cause) {
    super(message, cause);

const error = new Error("Boom!");
const customError = new CustomError("Another boom!", error);

console.log(customError); // Automatically prints full stack trace using `fullStack(this)`.
console.log(customError.cause); // Check causes via the `.cause` property.

console.log(customError instanceof Error); //=> true


Inspired by verror, and others, but created lighter and without core dependencies for browser usage.

Other references:


Apache 2.0

Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Typescript (256,310
Stack (16,082
Error (15,085
Make (4,702
Error Reporting (4,467
Error Handling (1,066
Stacktrace (806