Skip to content

Commit

Permalink
Merge pull request #1 from soxhub/error-supression
Browse files Browse the repository at this point in the history
Error supression
  • Loading branch information
rajivm committed Nov 21, 2016
2 parents f7c687b + 8101c04 commit 1f3f0f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -37,9 +37,13 @@
var rollbar = require('rollbar');
var util = require('util');

/*
** options (example)
** - supressedErrorMessages = ['Missing authentication', 'Not found'];
*/
exports.register = function (server, options, next) {
var supressedErrorMessages = options.supressedErrorMessages || [];
var rollbarKey = options.accessToken;

var rollbarOpts = options;
rollbarOpts.environment = rollbarOpts.environment || process.env.NODE_ENV;
rollbarOpts.exitOnUncaughtException = typeof options.exitOnUncaughtException !== 'undefined' ?
Expand All @@ -54,8 +58,7 @@ exports.register = function (server, options, next) {

server.ext('onPreResponse', function onPreResponse(request, next) {
var response = request.response;

if (response.isBoom) {
if (response.isBoom && supressedErrorMessages.indexOf(response.message) === -1) {
rollbar.handleErrorWithPayloadData(response, response.output, request, logError);
}

Expand Down Expand Up @@ -139,4 +142,4 @@ function formatReq(request) {
};

return rollbarRequest;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rollbar-hapi",
"version": "0.0.3",
"version": "0.0.4",
"description": "A Hapi plugin for rollbar painless integration",
"author": "Evangelos Pappas <[email protected]>",
"engine": "node >= 0.10.x",
Expand Down

0 comments on commit 1f3f0f6

Please sign in to comment.