error-reporting
v0.0.3
Published
Reporting errors to email.
Downloads
2
Readme
error-reporting
Reporting errors to email.
Usage
Usage of this library is fairly simple. All you need to do is to initialize the library and nodemailer's transport and you can start reporting errors immediately.
var error = require('error-reporting');
var nodemailer = require('nodemailer');
// initialize transport
var ses = require('nodemailer-ses-transport');
var transporter = nodemailer.createTransport(ses({
accessKeyId: 'AWSACCESSKEY',
secretAccessKey: 'AWS/Secret/key'
}));
// initialize error reporting library
error.init({
transporter: transporter,
from: '[email protected]',
to: '[email protected]',
subject: 'My Awesome application has encountered an error',
interval: 60
});
// to report an error, just call error.report() anywhere in your application
var err = new Error();
error.report('A message about your error', {objectThatCasedTheError: {foo: 'bar'}}, err.stack);
Configuration options
- transporter - Transporter for Nodemailer, see more about SMTP transporter or other transporters. If transporter is not provided, then all errors are printed out to console with stacktrace.
- from - Any address format accepted by Nodemailer
- to - Any address format accepted by Nodemailer
- cc - Array of addresses, format must be accepted by Nodemailer, default is empty array
- subject - Subject of email, default is 'Error'
- interval - Interval in seconds for sending messages to email, defaults to 30. If set to 0 or null all errors are sent immediately. Please beware, as this might flood your email server.
Changelog
Changelog is available under GitHub releases section.