This topic has not yet been rated - Rate this topic

number Property

Returns or sets the numeric value associated with a specific error.

object.number
object

Any instance of the Error object.

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 determine the actual error code, use the & (bitwise And) operator to combine the number property with the hexadecimal number 0xFFFF.

The following example causes an exception to be thrown and displays the error code that is derived from the error number.

try
{
    var arr = new Array(-1);
}
catch(e)
{
    print ("Error Code: " + (e.number & 0xFFFF));
    print ("Facility Code: " + (e.number>>16 & 0x1FFF));
    print ("Error Message: " + e.message);
    print ("Error Name: " + e.name);
}

The output of this code is as follows.

Error Code: 5029
Facility Code: 10
Error Message: Array length must be zero or a positive integer
Error Name: RangeError
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.