Comparing version 1.3.1 to 1.3.2
10
index.js
'use strict'; | ||
var envIs = require('101/env-is'); | ||
var noop = require('101/noop'); | ||
var exists = require('101/exists'); | ||
@@ -37,3 +36,3 @@ var rollbar = require('rollbar'); | ||
* executing under a test environment (i.e. `process.env.NODE_ENV !== 'test'`). | ||
* @return `true` If ErrorCat should use rollbar, `false` otherwise. | ||
* @return {Boolean} `true` If ErrorCat should use rollbar, `false` otherwise. | ||
*/ | ||
@@ -131,8 +130,11 @@ ErrorCat.prototype.canUseRollbar = function () { | ||
* @param {Error} err The error to report. | ||
* @param {object} [req] optional request to report. | ||
*/ | ||
ErrorCat.prototype.report = function (err) { | ||
ErrorCat.prototype.report = function (err, req) { | ||
if (!exists(err) || err.report === false || !this.canUseRollbar()) { | ||
return; | ||
} | ||
rollbar.handleErrorWithPayloadData(err, { custom: (err.data || {}) }, noop); | ||
// rollbar.handleErrorWithPayloadData usage: | ||
// https://github.com/rollbar/node_rollbar/blob/a03b3a6e6e0a2734e2657cbf41e21927003f505d/lib/notifier.js#L359 | ||
rollbar.handleErrorWithPayloadData(err, { custom: (err.data || {}) }, req); | ||
}; | ||
@@ -139,0 +141,0 @@ |
{ | ||
"name": "error-cat", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "A friendly feline companion that helps you create, track, and report errors.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -20,3 +20,3 @@ # error-cat | ||
// Report Errors via Rollbar | ||
ErrorCat.report(anotherError); | ||
ErrorCat.report(anotherError, req); | ||
``` | ||
@@ -144,3 +144,3 @@ | ||
#### {void} `report(err)` | ||
#### {void} `report(err, [req])` | ||
Reports the given error via Rollbar. This method is automatically bypassed if | ||
@@ -147,0 +147,0 @@ `ErrorCat.canUseRollbar()` returns false (see above). |
23534
499