Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9125714
error-to-string.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
error-to-string.js
View Options
'use strict'
;
var
DESCRIPTORS
=
require
(
'../internals/descriptors'
);
var
fails
=
require
(
'../internals/fails'
);
var
anObject
=
require
(
'../internals/an-object'
);
var
create
=
require
(
'../internals/object-create'
);
var
normalizeStringArgument
=
require
(
'../internals/normalize-string-argument'
);
var
nativeErrorToString
=
Error
.
prototype
.
toString
;
var
INCORRECT_TO_STRING
=
fails
(
function
()
{
if
(
DESCRIPTORS
)
{
// Chrome 32- incorrectly call accessor
// eslint-disable-next-line es/no-object-defineproperty -- safe
var
object
=
create
(
Object
.
defineProperty
({},
'name'
,
{
get
:
function
()
{
return
this
===
object
;
}
}));
if
(
nativeErrorToString
.
call
(
object
)
!==
'true'
)
return
true
;
}
// FF10- does not properly handle non-strings
return
nativeErrorToString
.
call
({
message
:
1
,
name
:
2
})
!==
'2: 1'
// IE8 does not properly handle defaults
||
nativeErrorToString
.
call
({})
!==
'Error'
;
});
module
.
exports
=
INCORRECT_TO_STRING
?
function
toString
()
{
var
O
=
anObject
(
this
);
var
name
=
normalizeStringArgument
(
O
.
name
,
'Error'
);
var
message
=
normalizeStringArgument
(
O
.
message
);
return
!
name
?
message
:
!
message
?
name
:
name
+
': '
+
message
;
}
:
nativeErrorToString
;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jun 21, 9:14 PM (4 w, 22 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3364505
Attached To
rDWAPPS Web applications
Event Timeline
Log In to Comment