
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
global-error-handler
Advanced tools
This package is for handling error in any type of Javascript application in an aspect oriented way.
This package is for handling error in any type of Javascript application in an aspect oriented way.
npm install global-error-handler
Main idea of this implementation is to handle different types of errors in their own custom way without introducing handler implementation to the code where you throw the error.
You would reap the benefit of this package in an application that you would have
multiple types of errors and each of them has different way of being handled.
To understand better, see the Usage section.
There are two ways of registering an ErrorHandler.
// someMain.js
import { GlobalErrorHandler } from 'global-error-handler';
const globalErrorHandler = new GlobalErrorHandler();
const someHandler = error => {
// processing error code comes here
}
globalErrorHandler.register({
key: 'someKey',
handler: someHandler
})
// someComponent.js
const globalErrorHandler = require('./path/to/global-error-handler/instance')
globalErrorHandler.handle(new Error('Some Error'), 'someError');
...
const someError = { message: 'someError' };
globalErrorHandler.handle(someError, 'someError');
...
Error classYou can also reigster an ErrorHandler by passing a class which inherits Error
class which is defined by default in Javascript.
This way you can have the benefit of being able to use throw keyword and make your app
catch the error and pass it to GlobalErrorHandler to handle it.
// someMain.js
import { GlobalErrorHandler } from 'global-error-handler';
const globalErrorHandler = new GlobalErrorHandler();
class SomeError extends Error {}
const someHandler = error => {
// processing error code comes here
}
globalErrorHandler.register({
key: SomeError,
handler: someHandler
})
// in a browser app
window.onerror = (message, url, line, column, error) => {
globalErrorHandler.handle(error);
};
// someComponent.js
const SomeError = require('./path/to/SomeError');
...
throw new SomeError('Some message');
...
FAQs
This package is for handling error in any type of Javascript application in an aspect oriented way.
We found that global-error-handler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.