You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
686 B
24 lines
686 B
"use strict"; |
|
|
|
var isPrototype = require("../prototype/is"); |
|
|
|
var objectToString = Object.prototype.toString |
|
, objectTaggedString = objectToString.call(new Error()); |
|
|
|
module.exports = function (value) { |
|
if (!value) return false; |
|
|
|
// Sanity check (reject objects which do not expose common Error interface) |
|
try { |
|
if (typeof value.message !== "string") return false; |
|
} catch (error) { |
|
return false; |
|
} |
|
|
|
// Ensure its native Error object (has [[ErrorData]] slot) |
|
// Note: it's not 100% precise as string tag may be overriden |
|
// and other objects can be hacked to expose it |
|
if (objectToString.call(value) !== objectTaggedString) return false; |
|
|
|
return !isPrototype(value); |
|
};
|
|
|