# make-error-cause **Repository Path**: mirrors_mk-pmb/make-error-cause ## Basic Information - **Project Name**: make-error-cause - **Description**: Make your own error types, with a cause! - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-25 - **Last Updated**: 2026-04-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Make Error Cause [![NPM version][npm-image]][npm-url] [![NPM downloads][downloads-image]][downloads-url] [![Build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url] > Make your own nested error types! ## Features * Compatible with Node and browsers * Works with `instanceof` * Use `error.stack` and `error.name` * Output full cause with `toString` * Extends [make-error](https://github.com/julien-f/js-make-error) ## Installation ```sh npm install make-error-cause --save ``` ## Usage Usages from [`make-error`](https://github.com/julien-f/js-make-error#usage). The only difference is that errors accept a second argument known as the error "cause". The cause is used to wrap original errors with more intuitive feedback - for instance, wrapping a raw database error in a HTTP error. ```js const CustomError = makeErrorCause('CustomError') const cause = new Error('boom!') const error = new CustomError('something bad', cause) error.toString() //=> "CustomError: something bad\nCaused by: boom!" error.stack // Works! error.cause.stack // Handy! ``` ## Attribution Inspired by [`verror`](https://www.npmjs.com/package/verror), and others, but created lighter and without core dependencies for browser usage. ## License Apache 2.0 [npm-image]: https://img.shields.io/npm/v/make-error-cause.svg?style=flat [npm-url]: https://npmjs.org/package/make-error-cause [downloads-image]: https://img.shields.io/npm/dm/make-error-cause.svg?style=flat [downloads-url]: https://npmjs.org/package/make-error-cause [travis-image]: https://img.shields.io/travis/blakeembrey/make-error-cause.svg?style=flat [travis-url]: https://travis-ci.org/blakeembrey/make-error-cause [coveralls-image]: https://img.shields.io/coveralls/blakeembrey/make-error-cause.svg?style=flat [coveralls-url]: https://coveralls.io/r/blakeembrey/make-error-cause?branch=master