-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathError.js
35 lines (29 loc) · 1.47 KB
/
Error.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
var noMessage = new Error();
var withMessage = Error("I have a message for you...");
WScript.Echo("Error.prototype.name: " + Error.prototype.name);
WScript.Echo("Error.prototype.message: " + Error.prototype.message);
WScript.Echo("Error.prototype.toString(): " + Error.prototype.toString());
//WScript.Echo("Error.prototype.constructor: " + Error.prototype.constructor);
WScript.Echo("noMessage.name: " + noMessage.name);
WScript.Echo("noMessage.message: " + noMessage.message);
WScript.Echo("noMessage.toString(): " + noMessage.toString());
WScript.Echo("withMessage.name: " + withMessage.name);
WScript.Echo("withMessage.message: " + withMessage.message);
WScript.Echo("withMessage.toString(): " + withMessage.toString());
Error.prototype.name = "TryNewName";
WScript.Echo("Changing Error.prototype.name to TryNewName...");
WScript.Echo("Error.prototype.name: " + Error.prototype.name);
WScript.Echo("withMessage.name: " + withMessage.name);
try
{
RangeError.prototype.message = "Range Error's prototype";
throw RangeError.prototype;
}
catch(ex)
{
WScript.Echo("Message: " + ex.message);
}