@mfederczuk/custom-exception
v1.4.0
Published
Custom Exception class
Downloads
4
Readme
Custom JavaScript Exception
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.