Check the exception name and output exception message : Exception « Development « JavaScript Tutorial






<html>
<head>
<title>Try Catch Example</title>
<script type="text/javascript">
try {
    eval("a ++ b");        //causes SyntaxError
} catch (oException) {
    if (oException.name == "SyntaxError") {
        alert("Syntax Error: " + oException.message);
    } else {
        alert("An unexpected error occurred: " + oException.message);
    }
}

</script>
</head>
<body>
</body>
</html>








4.7.Exception
4.7.1.Syntactic exception
4.7.2.Array index to large exception
4.7.3.Get Exception message
4.7.4.Exception handler will bypass the statements
4.7.5.Get Exception name
4.7.6.Check the exception name and output exception message
4.7.7.Check Exception type with instanceof operator
4.7.8.Throw exception out of a function