mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +00:00
Ensure _.isError works with subclasses values. [closes #1994]
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user