Skip to content

Commit

Permalink
Adds option to ignore specific errors.
Browse files Browse the repository at this point in the history
Fixes #14
  • Loading branch information
ipmb committed Jul 18, 2012
1 parent 3c6d915 commit f33324e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ cross-domain requests.
**signatureUrl** - Use a server side url to get a signature for the message.
See below in the "Security" section for more details.

**ignoreErrors** - An array of error messages that should not get passed to sentry. You'll probably want to set this to `["Script error"]`.


## Logging Errors

Expand Down
6 changes: 5 additions & 1 deletion src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
site: undefined,
signatureUrl: undefined,
fetchHeaders: false, // Generates a synchronous request to your server
testMode: false // Disables some things that randomize the signature
testMode: false, // Disables some things that randomize the signature
ignoreErrors: []
};

Raven.funcNameRE = /function\s*([\w\-$]+)?\s*\(/i;
Expand Down Expand Up @@ -353,6 +354,9 @@
type = message.name;
message = message.message;
}
if ($.inArray(message, self.options.ignoreErrors) >= 0) {
return;
}

label = lineno ? message + " at " + lineno : message;

Expand Down
7 changes: 7 additions & 0 deletions test/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,11 @@ $(document).ready(function() {
'the message should match');
});

test("should ignore errors passed in `ignoreErrors`", function() {
Raven.process("Error to ignore");

// Raven should bail before making an ajax call
equal(ajax_calls.length, 0);
});

});
3 changes: 2 additions & 1 deletion test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ <h2 id="qunit-userAgent"></h2>
"secretKey": "77ec8c99a8854256aa68ccb91dd9119d",
"servers": ["/"],
"signatureUrl": null,
"testMode": true
"testMode": true,
"ignoreErrors": ["Error to ignore"]
};
Raven.config(config_opts);

Expand Down

0 comments on commit f33324e

Please sign in to comment.