main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 2 weeks ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var DESCRIPTORS = require('../internals/descriptors');
|
---|
3 | var fails = require('../internals/fails');
|
---|
4 | var anObject = require('../internals/an-object');
|
---|
5 | var normalizeStringArgument = require('../internals/normalize-string-argument');
|
---|
6 |
|
---|
7 | var nativeErrorToString = Error.prototype.toString;
|
---|
8 |
|
---|
9 | var INCORRECT_TO_STRING = fails(function () {
|
---|
10 | if (DESCRIPTORS) {
|
---|
11 | // Chrome 32- incorrectly call accessor
|
---|
12 | // eslint-disable-next-line es/no-object-create, es/no-object-defineproperty -- safe
|
---|
13 | var object = Object.create(Object.defineProperty({}, 'name', { get: function () {
|
---|
14 | return this === object;
|
---|
15 | } }));
|
---|
16 | if (nativeErrorToString.call(object) !== 'true') return true;
|
---|
17 | }
|
---|
18 | // FF10- does not properly handle non-strings
|
---|
19 | return nativeErrorToString.call({ message: 1, name: 2 }) !== '2: 1'
|
---|
20 | // IE8 does not properly handle defaults
|
---|
21 | || nativeErrorToString.call({}) !== 'Error';
|
---|
22 | });
|
---|
23 |
|
---|
24 | module.exports = INCORRECT_TO_STRING ? function toString() {
|
---|
25 | var O = anObject(this);
|
---|
26 | var name = normalizeStringArgument(O.name, 'Error');
|
---|
27 | var message = normalizeStringArgument(O.message);
|
---|
28 | return !name ? message : !message ? name : name + ': ' + message;
|
---|
29 | } : nativeErrorToString;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.