@@ -22,7 +22,9 @@ var _Raven = window.Raven,
22
22
extra : { }
23
23
} ,
24
24
authQueryString ,
25
- isRavenInstalled = false ;
25
+ isRavenInstalled = false ,
26
+
27
+ objectPrototype = Object . prototype ;
26
28
27
29
/*
28
30
* The core Raven singleton
@@ -232,7 +234,7 @@ var Raven = {
232
234
*/
233
235
captureException : function ( ex , options ) {
234
236
// If not an Error is passed through, recall as a message instead
235
- if ( ! ( ex instanceof Error ) ) return Raven . captureMessage ( ex , options ) ;
237
+ if ( ! isError ( ex ) ) return Raven . captureMessage ( ex , options ) ;
236
238
237
239
// Store the raw exception object for potential debugging and introspection
238
240
lastCapturedException = ex ;
@@ -399,11 +401,24 @@ function isString(what) {
399
401
return typeof what === 'string' ;
400
402
}
401
403
404
+ function isObject ( what ) {
405
+ return typeof what === 'object' && what !== null ;
406
+ }
407
+
402
408
function isEmptyObject ( what ) {
409
+ if ( ! isObject ( what ) ) return false ;
403
410
for ( var k in what ) return false ;
404
411
return true ;
405
412
}
406
413
414
+ // Sorta yanked from https://github.com/joyent/node/blob/aa3b4b4/lib/util.js#L560
415
+ // with some tiny modifications
416
+ function isError ( what ) {
417
+ return isObject ( what ) &&
418
+ objectPrototype . toString . call ( what ) === '[object Error]' ||
419
+ what instanceof Error ;
420
+ }
421
+
407
422
/**
408
423
* hasKey, a better form of hasOwnProperty
409
424
* Example: hasKey(MainHostObject, property) === true/false
@@ -412,7 +427,7 @@ function isEmptyObject(what) {
412
427
* @param {string } key to check
413
428
*/
414
429
function hasKey ( object , key ) {
415
- return Object . prototype . hasOwnProperty . call ( object , key ) ;
430
+ return objectPrototype . hasOwnProperty . call ( object , key ) ;
416
431
}
417
432
418
433
function each ( obj , callback ) {
0 commit comments