diff --git a/src/isErr.js b/src/isErr.js index 6deb353b..d2d1542f 100644 --- a/src/isErr.js +++ b/src/isErr.js @@ -21,5 +21,11 @@ _('objToStr'); exports = function(val) { - return objToStr(val) === '[object Error]'; + switch (objToStr(val)) { + case '[object Error]': + case '[object DOMException]': + return true; + default: + return val instanceof Error; + } }; diff --git a/test/isErr.js b/test/isErr.js index 3d0c1d5c..55eb08fd 100644 --- a/test/isErr.js +++ b/test/isErr.js @@ -1,5 +1,10 @@ +const isBrowser = util.isBrowser; + it('true', function() { expect(isErr(new Error())).to.be.true; + if (isBrowser) { + expect(isErr(new DOMException('test'))).to.be.true; + } }); it('false', function() {