Notice the four properties of the Error object: number, description, name, and message. The description property is identical to the message property. The duplication is for historic reasons, and from the need to comply with the ECMA standard. The name property is Error, and the number property is the number assigned to the object during construction.

Notice that we bit-anded the number property with the 16-bit all-one word. The higher order word may contain different information such as the facility code. The Errornumber property is saved in the lower 16-bit word.

You should also take notice that Error is not a .NET framework type. If you need to share your JScript .NET module with other languages, you'd better use the System.Exception type.

Put the example above in a file, say error.js, compile and run it. You should get the following Command Prompt window:

To learn more about exception handling, go to Column 118, JScript .NET, Part XII: Exception Handling.