@hawk.so/nodejs
Node.js errors Catcher module for Hawk.so
Usage
- Create an account and get an Integration Token.
- Add @hawk.so/nodejs package to your project.
Requireand initialize module.
Install
Use NPM or Yarn to install Catcher
$ npm install @hawk.so/nodejs --save$ yarn add @hawk.so/nodejsRequire HawkCatcher module
const HawkCatcher = require('@hawk.so/nodejs').default;Or
import HawkCatcher from '@hawk.so/nodejs';Init HawkCatcher
Initialize HawkCatcher in the entry file of your project by passing a project token.
const HAWK_TOKEN = 'eyJhb...VPsc';
HawkCatcher.init(HAWK_TOKEN);HawkCatcher adds listeners for uncaughtException and unhandledRejection itself.
Just write your code.
Catch exceptions manually
After initializing you can catch exceptions manually in try-catch constructions in any project's place.
Just require HawkCatcher and call .send() method.
try {
throw new Error('My lovely error');
} catch (e) {
HawkCatcher.send(e);
}If HawkCatcher was not initialized then .send() method will do nothing.