Newborn Programming Monsters

    @codexteam/hawk.nodejs

    1.2.1 • Public • Published

    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

    Keywords

    none

    Install

    npm i @codexteam/hawk.nodejs

    DownloadsWeekly Downloads

    15

    Version

    1.2.1

    License

    MIT

    Unpacked Size

    8.52 kB

    Total Files

    4

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar
    • avatar
    • avatar