-
-
Notifications
You must be signed in to change notification settings - Fork 809
/
Copy pathindex.js
80 lines (72 loc) · 1.26 KB
/
index.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
'use strict';
var toJSON = require( './../lib' );
var err = new Error( 'beep' );
console.log( toJSON( err ) );
/* =>
{
"type": "Error",
"name": "Error",
"message": "beep",
"stack": "..."
}
*/
err = new TypeError( 'invalid type' );
console.log( toJSON( err ) );
/* =>
{
"type": "TypeError",
"name": "TypeError",
"message": "invalid type",
"stack": "..."
}
*/
err = new SyntaxError( 'bad syntax' );
console.log( toJSON( err ) );
/* =>
{
"type": "SyntaxError",
"name": "SyntaxError",
"message": "bad syntax",
"stack": "..."
}
*/
err = new ReferenceError( 'unknown variable' );
console.log( toJSON( err ) );
/* =>
{
"type": "ReferenceError",
"name": "ReferenceError",
"message": "unknown variable",
"stack": "..."
}
*/
err = new URIError( 'bad URI' );
console.log( toJSON( err ) );
/* =>
{
"type": "URIError",
"name": "URIError",
"message": "bad URI",
"stack": "..."
}
*/
err = new RangeError( 'value out-of-range' );
console.log( toJSON( err ) );
/* =>
{
"type": "RangeError",
"name": "RangeError",
"message": "value out-of-range",
"stack": "..."
}
*/
err = new EvalError( 'eval error' );
console.log( toJSON( err ) );
/* =>
{
"type": "EvalError",
"name": "EvalError",
"message": "eval error",
"stack": "..."
}
*/