Returns or sets the numeric value associated with a specific error.
object.number |
Arguments
- object
-
Any instance of the Error object.
Remarks
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. To read off the actual error code, use the & (bitwise And) operator to combine the number property with the hexadecimal number 0xFFFF.
Example
The following example causes an exception to be thrown, and displays the error number.
| В | Copy Code |
|---|---|
function getAge(age) {
if(age < 0)
throw new Error(100)
print("Age is "+age+".");
}
// Pass the getAge an invalid argument.
try {
getAge(-5);
} catch(e) {
// Extract the error code from the error number.
print(e.number & 0xFFFF)
} | |
The output of this code is:
| В | Copy Code |
|---|---|
100 | |
Requirements
Applies To:
See Also
Ajax toolkit
Ajax website