Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

description Property 

Returns or sets the descriptive string associated with a specific error.


object.description
object

Required. An instance of an Error object.

The description property is a string containing an error message associated with a specific error. Use the value contained in this property to alert a user to an error that the script cannot handle.

The description and message properties refer to the same message; the description property provides backwards compatibility, while the message property complies with the ECMA standard.

The following example causes an exception to be thrown, and displays the description of the error.

function getAge(age) {
   if(age < 0)
      throw new Error("An age cannot be negative.")
   print("Age is "+age+".");
}

// Pass the getAge an invalid argument.
try {
   getAge(-5);
} catch(e) {
   print(e.description);
}

The output of this code is:

An age cannot be negative.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.