main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
959 bytes
|
Line | |
---|
1 | import baseGetTag from './_baseGetTag.js';
|
---|
2 | import isObjectLike from './isObjectLike.js';
|
---|
3 | import isPlainObject from './isPlainObject.js';
|
---|
4 |
|
---|
5 | /** `Object#toString` result references. */
|
---|
6 | var domExcTag = '[object DOMException]',
|
---|
7 | errorTag = '[object Error]';
|
---|
8 |
|
---|
9 | /**
|
---|
10 | * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
|
---|
11 | * `SyntaxError`, `TypeError`, or `URIError` object.
|
---|
12 | *
|
---|
13 | * @static
|
---|
14 | * @memberOf _
|
---|
15 | * @since 3.0.0
|
---|
16 | * @category Lang
|
---|
17 | * @param {*} value The value to check.
|
---|
18 | * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
|
---|
19 | * @example
|
---|
20 | *
|
---|
21 | * _.isError(new Error);
|
---|
22 | * // => true
|
---|
23 | *
|
---|
24 | * _.isError(Error);
|
---|
25 | * // => false
|
---|
26 | */
|
---|
27 | function isError(value) {
|
---|
28 | if (!isObjectLike(value)) {
|
---|
29 | return false;
|
---|
30 | }
|
---|
31 | var tag = baseGetTag(value);
|
---|
32 | return tag == errorTag || tag == domExcTag ||
|
---|
33 | (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
|
---|
34 | }
|
---|
35 |
|
---|
36 | export default isError;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.