function myFunction() {
var n;
try {
if(n == "") throw "n is Empty";
if(isNaN(n)) throw "n is not a number";
if(n < 0) throw "n is negative";
}
catch(err) {
document.write(err + "<br />");
document.write(err.message + "<br />");
}
}
document.write(myFunction());
/*
run:
n is not a number
undefined
undefined
*/