1 var isObjectLike = require('./isObjectLike');
3 /** `Object#toString` result references. */
4 var errorTag = '[object Error]';
6 /** Used for built-in method references. */
7 var objectProto = Object.prototype;
10 * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
13 var objectToString = objectProto.toString;
16 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
17 * `SyntaxError`, `TypeError`, or `URIError` object.
22 * @param {*} value The value to check.
23 * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
26 * _.isError(new Error);
32 function isError(value) {
33 return isObjectLike(value) &&
34 typeof value.message == 'string' && objectToString.call(value) == errorTag;
37 module.exports = isError;