ohcrash-client
v1.0.0
Published
Node.js client for reporting errors to OhCrash server
Downloads
2
Readme
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', {
// auto catch uncaught exceptions (default: `true`)
exceptions: true,
// exit after uncaught exception is reported (default: `true`)
exit: true,
// auto catch unhandled rejections (default: `true`)
rejections: true,
// properties that all errors inherit (default: `{}`)
// useful for sending values like app environment and version
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);
// error reported
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: '[email protected]'
});
License
MIT © Vadim Demedes