Error.isError true only for Error instances

This commit is contained in:
Mariusz Nowak
2013-10-07 18:56:39 +02:00
parent 4af7838821
commit 0463d7508a
+2 -5
View File
@@ -2,11 +2,8 @@
var toString = Object.prototype.toString
, id = toString.call(new Error())
, exceptionRe = /^\[object [a-zA-z0-9]*(?:Exception|Error)\]$/;
, id = toString.call(new Error());
module.exports = function (x) {
var xid;
return (x && ((x instanceof Error) || ((xid = toString.call(x)) === id) ||
xid.match(exceptionRe))) || false;
return (x && ((x instanceof Error) || (toString.call(x)) === id)) || false;
};