← Older revision
Revision as of 16:48, 18 August 2014
Line 1:
Line 1:
{{Page_Title}}
{{Page_Title}}
−
{{Flags}}
+
{{Flags
−
{{Summary_Section|Contains information about errors.
+
|State=Ready to Use
−
+
|Checked_Out=No
+
}}
+
{{Summary_Section|Contains information about errors.
}}
+
{{JS_Syntax
+
|Formats={{JS Syntax Format
+
|Format=errorObj = new Error()
+
}}{{JS Syntax Format
+
|Format=errorObj = new Error([ number ])
+
}}{{JS Syntax Format
+
|Format=errorObj = new Error([ number [, description ]])
}}
}}
−
{{JS_Syntax|Formats={{JS_Syntax_Format
+
|Values={{
JS Syntax Parameter
−
|Format= errorObj = new Error()}}{{JS_Syntax_Format
+
−
|Format= errorObj = new Error([ number ])}}{{JS_Syntax_Format
+
−
|Format= errorObj = new Error([ number [, description ]])}}
+
−
|Values={{
JS_Syntax_Parameter
+
|Name=errorObj
|Name=errorObj
|Required=Required
|Required=Required
−
|Description=The variable name to which the Error object is assigned.}}{{
JS_Syntax_Parameter
+
|Description=The variable name to which the Error object is assigned.
+
}}{{
JS Syntax Parameter
|Name=number
|Name=number
|Required=Optional
|Required=Optional
−
|Description=Numeric value assigned to an error. Zero if omitted.}}{{
JS_Syntax_Parameter
+
|Description=Numeric value assigned to an error. Zero if omitted.
+
}}{{
JS Syntax Parameter
|Name=description
|Name=description
|Required=Optional
|Required=Optional
−
|Description=Brief string that describes an error. Empty string if omitted.
}}
+
|Description=Brief string that describes an error. Empty string if omitted.
}}
}}
−
{{Remarks_Section
−
|Remarks=Whenever a run-time error occurs, an instance of the Error object is created to describe the error. This instance has two intrinsic properties that contain the description of the error ( '''description''' property) and the error number ( '''number''' property).
−
−
An error number is a 32-bit value. The upper 16-bit word is the facility code, while the lower word is the actual error code.
−
−
Error objects can also be explicitly created, using the syntax shown above, or thrown using the throw statement. In both cases, you can add any properties you choose to expand the capability of the Error object.
−
−
Typically, the local variable that is created in a '''try...catch''' statement refers to the implicitly created Error object. As a result, you can use the error number and description in any way you choose.
}}
}}
+
{{JS_Return_Value}}
{{Examples_Section
{{Examples_Section
|Not_required=No
|Not_required=No
−
|Examples={{
Single_Example
+
|Examples={{
Single Example
|Language=JavaScript
|Language=JavaScript
|Description=The following example illustrates the use of the Error object.
|Description=The following example illustrates the use of the Error object.
−
+
|Code=function checkInput(x) {
−
|Code= function checkInput(x) {
+
try
try
{
{
Line 46:
Line 45:
}
}
}
}
−
}}{{
Single_Example
+
}}{{
Single Example
|Language=JavaScript
|Language=JavaScript
|Description=The following example illustrates the use of the implicitly created Error object.
|Description=The following example illustrates the use of the implicitly created Error object.
−
+
|Code=try
−
|Code= try
+
{
{
// Cause an error.
// Cause an error.
Line 77:
Line 75:
// Number: 5009
// Number: 5009
// Description: 'y' is undefined
// Description: 'y' is undefined
−
}}}}
+
}}
+
}}
+
{{Remarks_Section
+
|Remarks=Whenever a run-time error occurs, an instance of the Error object is created to describe the error. This instance has two intrinsic properties that contain the description of the error ( '''description''' property) and the error number ( '''number''' property).
+
+
An error number is a 32-bit value. The upper 16-bit word is the facility code, while the lower word is the actual error code.
+
+
Error objects can also be explicitly created, using the syntax shown above, or thrown using the throw statement. In both cases, you can add any properties you choose to expand the capability of the Error object.
+
+
Typically, the local variable that is created in a '''try...catch''' statement refers to the implicitly created Error object. As a result, you can use the error number and description in any way you choose.
+
}}
+
{{Notes_Section}}
+
{{JS Object Listing
}}
==Methods==
==Methods==
[[javascript/Error/toString|toString Method (Error)]] {{!}} [[javascript/Date/valueOf|valueOf Method (Date)]]
[[javascript/Error/toString|toString Method (Error)]] {{!}} [[javascript/Date/valueOf|valueOf Method (Date)]]
==Properties==
==Properties==
[[javascript/Error/constructor|constructor Property (Error)]] {{!}} [[javascript/Error/description|number Property]] {{!}} [[javascript/Error/prototype|prototype Property (Error)]] {{!}} [[javascript/Error/stack|stack Property (Error)]] {{!}} [[javascript/Error/stackTraceLimit|stackTraceLimit Property (Error)]]
[[javascript/Error/constructor|constructor Property (Error)]] {{!}} [[javascript/Error/description|number Property]] {{!}} [[javascript/Error/prototype|prototype Property (Error)]] {{!}} [[javascript/Error/stack|stack Property (Error)]] {{!}} [[javascript/Error/stackTraceLimit|stackTraceLimit Property (Error)]]
+
+
{{Topics | JS Basic}}
{{See_Also_Section
{{See_Also_Section
|Manual_links=* [[javascript/operators/new{{!}}new Operator]]
|Manual_links=* [[javascript/operators/new{{!}}new Operator]]
Line 88:
Line 100:
* [[javascript/statements/var{{!}}var Statement]]
* [[javascript/statements/var{{!}}var Statement]]
}}
}}
−
{{Topics | JS Basic}}
+
{{
JS
Topics
−
+
|
JS Page Type=
JS Basic
+
|Applies to=
+
}}
{{External_Attribution
{{External_Attribution
|Is_CC-BY-SA=No
|Is_CC-BY-SA=No