Socket
Socket
Sign inDemoInstall

rollbar

Package Overview
Dependencies
Maintainers
3
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollbar - npm Package Compare versions

Comparing version 0.3.10 to 0.3.11

6

CHANGELOG.md
# Change Log
**0.3.11**
- Add `handleErrorWithPayloadData` function, exposing more of the Rollbar API when reporting errors. ([#29](https://github.com/rollbar/node_rollbar/pull/29))
**0.3.10**
- Fix edge case where multiple errors were not handled correctly. ([#28](https://github.com/rollbar/node_rollbar/issues/28))
**0.3.9**

@@ -4,0 +10,0 @@ - Add `verbose` configuration option, `true` by default.

13

lib/notifier.js

@@ -68,6 +68,13 @@ var http = require('http');

exports.handleError = function(err, req, callback) {
return exports.handleErrorWithPayloadData(err, {}, req, callback);
}
exports.handleErrorWithPayloadData = function(err, payloadData, req, callback) {
// Allow the user to call with an optional request and callback
// e.g. handleError(err, req, callback) or handleError(err, callback)
// or handleError(err)
// e.g. handleErrorWithPayloadData(err, payloadData, req, callback)
// or handleErrorWithPayloadData(err, payloadData, callback)
// or handleErrorPayloadData(err, payloadData)
if (typeof req === 'function') {

@@ -87,3 +94,3 @@ callback = req;

} else {
var data = buildBaseData();
var data = buildBaseData(payloadData);
data.body = {

@@ -90,0 +97,0 @@ trace: {

@@ -13,3 +13,3 @@ {

],
"version": "0.3.10",
"version": "0.3.11",
"repository": "git://github.com/rollbar/node_rollbar.git",

@@ -16,0 +16,0 @@ "author": "Rollbar, Inc. <support@rollbar.com>",

@@ -17,2 +17,5 @@ # Rollbar notifier for Node.js [![Build Status](https://secure.travis-ci.org/rollbar/node_rollbar.png?branch=master)](https://travis-ci.org/rollbar/node_rollbar)

rollbar.reportMessage("Hello world!");
// more is required to automatically detect and report errors.
// keep reading for details.
```

@@ -93,3 +96,3 @@

To report an exception that you have caught, use [`handleError`](https://github.com/rollbar/node_rollbar/blob/master/rollbar.js#L152):
To report an exception that you have caught, use [`handleError`](https://github.com/rollbar/node_rollbar/blob/master/rollbar.js#L152) or the full-powered [`handleErrorWithPayloadData`](https://github.com/rollbar/node_rollbar/blob/master/rollbar.js#L176):

@@ -120,2 +123,10 @@ ```js

rollbar.handleError(e, request, callback);
// to specify payload options - like extra data, or the level - use handleErrorWithPayloadData
rollbar.handleError(e, {level: "warning", custom: {someKey: "arbitrary value"}});
// can also take request and callback, like handleError:
rollbar.handleError(e, {level: "info"}, request);
rollbar.handleError(e, {level: "info"}, callback);
rollbar.handleError(e, {level: "info"}, request, callback);
}

@@ -157,3 +168,3 @@ ```

`handleError`, `reportMessage`, and `reportMessageWithPayloadData` all accept a `request` parameter as the second, third, and third arguments respectively. If it is a function, it will be called and the result used.
`handleError`, `reportMessage`, `handleErrorWithPayloadData`, and `reportMessageWithPayloadData` all accept a `request` parameter as the second, third, third, and third arguments respectively. If it is a function, it will be called and the result used.

@@ -213,3 +224,3 @@ If you're using Express, just pass the express request object. If you're using something custom, pass an object with these keys (all optional):

<dt>environment</dt>
<dd>The environment the code is running in.
<dd>The environment the code is running in, e.g. "production"

@@ -240,3 +251,3 @@ Default: `'unspecified'`

Default: `os.hostname()`
Default: hostname returned from `os.hostname()`
</dd>

@@ -243,0 +254,0 @@

@@ -175,3 +175,28 @@ var api = require('./lib/api');

/*
* handleErrorWithPayloadData(err, payloadData, request, callback)
*
* The same as handleError() but allows you to specify additional data to log along with the error,
* as well as other payload options.
*
* Parameters:
* err - an Exception/Error instance
* payloadData - an object containing keys/values to be sent along with the error report.
* e.g. {level: "warning"}
* request - optional request object to send along with the message
* callback - optional callback that will be invoked depending on the handler method used.
* Should take a single parameter to denote if there was an error.
*
* Examples:
*
* rollbar.handleError(new Error("Could not connect to database"), {level: "warning"});
* rollbar.handleError(new Error("Could not connect to database"),
* {custom: {someKey: "its value, otherKey: ["other", "value"]}});
* rollbar.handleError(new Error("error message"), {}, req, function(err) {
* // error was queued/sent to rollbar
* });
*/
exports.handleErrorWithPayloadData = notifier.handleErrorWithPayloadData;
exports.shutdown = function(callback) {

@@ -178,0 +203,0 @@ notifier.shutdown(callback);

@@ -12,2 +12,38 @@ var assert = require('assert');

var suite = vows.describe('notifier').addBatch({
'handleError with a normal error': {
topic: function() {
var test = function() {
var x = thisVariableIsNotDefined;
};
try {
test();
} catch (e) {
notifier.handleError(e, this.callback);
}
},
'verify no error is returned': function(err, resp) {
assert.isNull(err);
assert.isObject(resp);
assert.include(resp, 'ids');
// TODO - verify contents of payload
}
},
'handleErrorWithPayloadData with a normal error': {
topic: function() {
var test = function() {
var x = thisVariableIsNotDefined;
};
try {
test();
} catch (e) {
notifier.handleErrorWithPayloadData(e, {level: "warning"}, this.callback);
}
},
'verify no error is returned': function(err, resp) {
assert.isNull(err);
assert.isObject(resp);
assert.include(resp, 'ids');
// TODO - verify contents of payload
}
},
'handleError with an Error that has a missing stack': {

@@ -14,0 +50,0 @@ topic: function() {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc