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

message Property (JavaScript)

Returns an error message string.

errorObj.message
errorObj

Required. Instance of Error object.

The message property returns a string that contains an error message associated with a specific error.

The description and message properties provide the same functionality. The description property provides backwards compatibility; the message property complies with the ECMA standard.

The following example causes a TypeError exception to be thrown and displays the name of the error and its message.

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

The output of this code is as follows.

Error Message: 'y' is undefined
Error Code: 5009
Error Name: TypeError

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards. See Version Information.

Applies To: Error Object (JavaScript)

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.