Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Make intercept preserve function details like wrap
Browse files Browse the repository at this point in the history
  • Loading branch information
LewisJEllis committed Nov 1, 2016
1 parent 89305b2 commit c6309c5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,28 @@ extend(Raven.prototype, {
return wrapped;
},

intercept: function (cb) {
intercept: function (opts, func) {
var self = this;
var wrapped = function () {
var err = arguments[0];
if (err instanceof Error) {
self.captureException(err, opts);
} else {
cb.apply(null, arguments);
func.apply(null, arguments);
}
};

// repetitive with wrap
for (var property in func) {
if ({}.hasOwnProperty.call(func, property)) {
wrapped[property] = func[property];
}
}
wrapped.prototype = func.prototype;
wrapped.__raven__ = true;
wrapped.__inner__ = func;

return wrapped;
},

setContext: function setContext(ctx) {
Expand Down

0 comments on commit c6309c5

Please sign in to comment.