npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

all-error-handler

1.4.0 • Public • Published

all-error-handler

АllЕrrorHandler provides you a object, which will listen for error events and then call a provided callback function.

АllЕrrorHandler package is exported as a UMD module.

code style: prettier npm downlodas Build Status devDependencies Status Known Vulnerabilities

Installation

In a browser:

<script src="node_modules/all-error-handler/index.min.js"></script>

In Node.js:

let AllErrorHandler = require("all-error-handler");

Usage

// Initialize object and pass a callback function to it
let errorHandler = new AllErrorHandler(err => {
    console.log(`Error occured - ${err}`);
});
 
//Test
throw new Error("Foo"); // Error occured - Error: Foo
//  at Object.<anonymous> ...

Params

new AllErrorHandler({Function}callback, {Boolean}startListening = true)

-- callback - pass a function which will be called after an Error is throwed.

-- startListening - if true it will start listining for the errors when the object is created.

Methods:

startListening();

-- Start listening for error events

errorHandler.startListening();

stopListening();

-- Stop listening for error events

errorHandler.stopListening();

dispose();

-- Call before setting the object to null to prevent memory leak

errorHandler.dispose();
errorHandler = null;

License

MIT

install

npm i all-error-handler

Downloadsweekly downloads

1,334

version

1.4.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability