forked from nkronlage/JavaScripture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.jsdoc
More file actions
84 lines (64 loc) · 1.34 KB
/
error.jsdoc
File metadata and controls
84 lines (64 loc) · 1.34 KB
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
81
82
83
Error : Object
An object thrown when an error occurs.
There are several specific constructor functions for different types of
error conditions:
**EvalError**,
**RangeError**,
**ReferenceError**,
**SyntaxError**,
**TypeError**,
**URIError**,
**NativeError**.
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.11
----
Error(message : String) : Error
Same as %%#new_Error_String|**new Error(message)**%%.
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.11.1.1
----
new Error(message : String) : Error
Creates a new **Error** with the specified **message** that describes the error.
<example>
var divide = function(x, y) {
if (y === 0) {
throw new Error('divide by zero');
}
return x / y;
};
try {
console.log(divide(10, 0));
}
catch (error) {
console.log(error.name);
console.log(error.message);
}
</example>
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.11.2.1
----
prototype.name : String
The type of error.
<example>
try {
foo;
}
catch (error) {
console.log(error.name);
}
</example>
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.11.4.2
----
prototype.message : String
A human readable message that describes the error.
<example>
try {
foo;
}
catch (error) {
console.log(error.message);
}
</example>
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.11.4.3