spacer
Yehuda Shiran September 20, 2002
Extracting Information from the Error Object
Tips: September 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management
Let's look at the following try...catch statement example:

  try {
    throw new Error(35,"null object, call your vendor");
  } 
  catch(e) {
    print("e is: " + e)
    print("e.number is: " + (e.number & 0xFFFF));
    print("e.description is: " + e.description);
    print("e.name is: " + e.name);
    print("e.message is: " + e.message);
  }
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 Error number 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.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Administering MySQL Databases on the Web Using PHP · Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
So what is an Oracle Nested Table? · E-Discovery Architectures 101 · eBay Embraces Big Sellers, Cyber Monday Trends