Node.js catcher for Hawk
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
src
.eslintrc
.gitignore
.npmignore
README.md
package.json

README.md

hawk.nodejs

Node.js errors Catcher module for Hawk.so

Usage

Register an account and get a project token.

Install module

Use npm to install Catcher

$ npm install @codexteam/hawk.nodejs --save

Download and require node.js file

You can download this repository and require Hawk.nodejs file in your project.

require './hawk.nodejs/src/hawk';

Init HawkCatcher

Create an instance with token to the entry point of your project.

var hawkCatcher = require('@codexteam/hawk.nodejs')({
  accessToken: "69d86244-f792-47ad-8e9a-23fee358e062"
});

Custom Hawk server

If you want to use custom Hawk server then pass a url to this catcher.

var hawkCatcher = require('@codexteam/hawk.nodejs')({
  accessToken: "69d86244-f792-47ad-8e9a-23fee358e062",
  url: "https://myownhawk.com/catcher/nodejs"
});

Usage

You can catch global Exceptions

hawkCatcher.initGlobalCatcher();

If you provide callback function – it will be called after Exception would be caught by Hawk.

hawkCatcher.initGlobalCatcher(function (error, response, body) {
  console.log('Hawk response: ', body);
});

Catch exception manually

You can catch exceptions by yourself without enabling handlers.

try {
  throw new Exception("");
} catch (e) {
  hawkCatcher.catchException(e, {comment: "Exception in general module"});
}

The catchException method has two optional arguments:

  • custom - [optional] dictionary with the following structure
    • comment - error description
  • callback - [optional] callback function
try {
  throw new Exception('');
} catch (e) {
  hawkCatcher.catchExceptionPromise(e, {comment: 'Exception in general module'})
    .then(function (result) {
      console.log(result);
    })
    .catch(function (err) {
      console.log('Error occured: ', err);
    });
}

The catchExceptionPromise method returns Promise and has one optional argument:

  • custom - [optional] dictionary with the following structure
    • comment - error description

Links

Repository: https://github.com/codex-team/hawk.nodejs

Report a bug: https://github.com/codex-team/hawk.nodejs/issues

CodeX Team: https://ifmo.su