Ensure _.isError works with subclasses values. [closes #1994]

This commit is contained in:
John-David Dalton
2016-02-12 15:47:27 -08:00
parent b3ebb3c3d3
commit df0ecd2a93
2 changed files with 41 additions and 25 deletions

View File

@@ -9761,8 +9761,11 @@
* // => false
*/
function isError(value) {
return isObjectLike(value) &&
typeof value.message == 'string' && objectToString.call(value) == errorTag;
if (!isObjectLike(value)) {
return false;
}
var Ctor = value.constructor;
return typeof Ctor == 'function' && objectToString.call(Ctor.prototype) == errorTag;
}
/**
@@ -13121,7 +13124,7 @@
try {
return apply(func, undefined, args);
} catch (e) {
return isObject(e) ? e : new Error(e);
return isError(e) ? e : new Error(e);
}
});