@mfederczuk/custom-exception

Custom Exception class


Keywords
exception, error, custom-exception, javascript, javascript-library, js, ts, typescript, typescript-library
Licenses
MPL-2.0/Apache-2.0
Install
npm install @mfederczuk/custom-exception@1.1.0

Documentation

Custom JavaScript Exception

version: 1.4.0 Changelog

About

A custom JavaScript exception class.

Usage

Just extend the Exception class and call the super constructor from yours.
It's a good idea to have an optional cause parameter that you pass to the super constructor call as well.

import Exception from "@mfederczuk/custom-exception";

class CustomException extends Exception {
	constructor(readonly n: number, cause: (Exception | Error | null) = null) {
		super(`custom message ${n}`, cause);
	}
}

throw new CustomException(12);

Installation

Using npm:

npm i @mfederczuk/custom-js-exception

Using Yarn:

yarn add @mfederczuk/custom-js-exception

Contributing

Read through the Contribution Guidelines if you want to contribute to this project.

License

Custom JavaScript Exception is licensed under both the Mozilla Public License 2.0 AND the Apache License 2.0.
For more information about copying and licensing, see the COPYING.txt file.