
Error reporting client for OhCrash microservice.
OhCrash is a tiny microservice, that creates issues on GitHub for all reported errors.
Learn more at OhCrash repository.
Installation
$ npm install ohcrash-client --save
Usage
Set up an OhCrash microservice and deploy it.
There's no hosted version, so a URL to your own server is required.
require('ohcrash-client').register('https://my-ohcrash.now.sh');
That's it, from now on uncaught exceptions and unhandled rejections will be reported to the server.
Client's behavior can be customized via options.
Configuration
Client accepts an options object as a second argument, which can customize some of its behavior.
require('ohcrash-client').register('https://my-ohcrash.now.sh', {
exceptions: true,
exit: true,
rejections: true,
globalProps: {
env: process.env.NODE_ENV,
version: '1.0.0'
}
});
Custom reporting
It is also possible to report errors manually by using report().
const ohcrash = require('ohcrash-client').register('https://my-ohcrash.now.sh');
const err = new Error('I know this error');
await ohcrash.report(err);
Errors can also have GitHub issue labels assigned to them:
ohcrash.report(err, {
labels: ['priority', 'bug', 'help wanted']
});
Any additional properties can be assigned as well, they will be included in the GitHub issue.
For example, error could have user's email assigned to it:
ohcrash.report(err, {
user: 'john@doe.com'
});
License
MIT © Vadim Demedes