Skip to content

Commit

Permalink
remove patchGlobal
Browse files Browse the repository at this point in the history
Leave this up to the application or other logging framework. Some users
will want to handle this with 'once' versus 'on'. Keep module focused on
interfacing with sentry instead of being a general purpose catch all
logger.
  • Loading branch information
defunctzombie committed Oct 10, 2012
1 parent a1c119c commit c5f8bfa
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 54 deletions.
11 changes: 0 additions & 11 deletions README.md
Expand Up @@ -79,17 +79,6 @@ Optionally set the name for the client to use. [What is name?](http://raven.read
### SENTRY_SITE
Optionally set the site for the client to use. [What is site?](http://raven.readthedocs.org/en/latest/config/index.html#site)

## Catching global errors
For those times when you don't catch all errors in your application. ;)

```javascript
client.patchGlobal();
// or
raven.patchGlobal(client);
// or
raven.patchGlobal('{{ SENTRY_DSN }}');
```

## Methods
```javascript
new raven.Client(dsn[, options])
Expand Down
13 changes: 0 additions & 13 deletions lib/client.js
Expand Up @@ -129,16 +129,3 @@ Client.prototype.captureQuery = function captureQuery(query, engine, kwargs, cb)
return result;
};

Client.prototype.patchGlobal = function patchGlobal() {
module.exports.patchGlobal(this);
};

module.exports.patchGlobal =
module.exports.patch_global = function patchGlobal(client) {
client = (client instanceof Client) ? client : new Client(client);
process.on('uncaughtException', function(err) {
client.captureError(err, function(result) {
node_util.log('uncaughtException: '+client.getIdent(result));
});
});
};
30 changes: 0 additions & 30 deletions test/raven.client.js
Expand Up @@ -192,34 +192,4 @@ describe('raven.Client', function(){
client.captureError(new Error('wtf?'));
});
});

describe('#patchGlobal()', function(){
it('should add itself to the uncaughtException event list', function(){
var before = process._events.uncaughtException;
client.patchGlobal();
process._events.uncaughtException.length.should.equal(before.length+1);
process._events.uncaughtException = before; // patch it back to what it was
});

it('should send an uncaughtException to Sentry server', function(done){
var scope = nock('https://app.getsentry.com')
.filteringRequestBody(/.*/, '*')
.post('/api/store/', '*')
.reply(200, 'OK');

// remove existing uncaughtException handlers
var before = process._events.uncaughtException;
process.removeAllListeners('uncaughtException');

client.on('logged', function(){
// restore things to how they were
process._events.uncaughtException = before;

scope.done();
done();
});
client.patchGlobal();
process.emit('uncaughtException', new Error('derp'));
});
});
});

0 comments on commit c5f8bfa

Please sign in to comment.