Error.number

Non-standard. Do not use!
This object is a Microsoft extension and is only supported in Internet Explorer.

The Error.number property returns or sets the numeric value associated with a specific error. The Error object's default property is number.

Syntax

object  
.number [= errorNumber]  

Parameters

Object
Any instance of the Error object.
errorNumber
An integer representing an error.

Remarks

An error number is a 32-bit value. The upper 16-bit word is the facility code, and the lower word is the error code. To determine the 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 code that is derived from the error number.

try  
    {  
    // Cause an error.  
    var x = y;  
    }  
catch(e)  
    {  
    document.write ("Error Code: ");  
    document.write (e.number & 0xFFFF)  
    document.write ("<br />");  

    document.write ("Facility Code: ")  
    document.write(e.number>>16 & 0x1FFF)  
    document.write ("<br />");  

    document.write ("Error Message: ")  
    document.write (e.message)  
    }

Example

The output of this code is as follows.

Error Code: 5009  
Facility Code: 10  
Error Message: 'y' is undefined

Requirements

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported in Store apps (Windows 8 and Windows Phone 8.1).

Applies ToError Object

See Also

Document Tags and Contributors

Contributors to this page: Llamaless, ExE-Boss, khorne3, erikadoyle
Last updated by: Llamaless,