Export (0) Print
Expand All

number Property

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.

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:

100

Requirements

Version 5

See Also

description Property | message Property | name Property

Applies To: Error Object

Show:
© 2014 Microsoft