Hi all, I was wondering if any of you have tried catching errors such as RangeError, ReferenceError and TypeError using JavaScript's exception handling mechnism?
For instance for RangeError:
try {
var anArray = new Array(-1);
// an array length must be positive
throw new RangeError("must be positive!")
}
catch (error) {
alert(error.message);
alert(error.name);
}
finally {
alert("ok, all is done!");
}
In the above case, am i throwing a new RangeError object?
Cos my code example at alert(error.message) doesnt show the user defined message of "must be positive".
What can I do to throw my own RangeError object ( and ReferenceError, TypeError ) ?
Best.