October 18, 2000 - Creating Error Messages
October 18, 2000 Creating Error Messages Tips: October 2000
Yehuda Shiran, Ph.D.
|
Error
object is constructed with two arguments:
number
. The error number. Zero, if no number
is provided.
description
. A string that describes the error. Empty, if no description
is provided.
The following statement creates an instance of the Error
object:
var myError = Error(31, "Fatal error has been detected. Failed in a consistency check. Please call your vendor.");
The Error
object supports two properties, matching the arguments above: number
and description
. You can both read as well as set them. The following code prints a message, consisting of the error number and its description:
alert("Error No. " + myError.number + ":" + "\n" + myError.description);
We have added the constructor above to this tip, and now you can try and print both properties of myError
.