Get Exception message in JavaScript
Description
The following code shows how to get Exception message.
Example
<html>
<head>
<script type="text/javascript">
try {<!--from w ww . ja va2 s. com-->
window.nonExistentFunction();
document.writeln("Method completed.");
} catch (oException) {
document.writeln("An exception occurred: " + oException.message);
} finally {
document.writeln("End of try...catch test.");
}
</script>
</head>
<body>
</body>
</html>
The code above generates the following result.
Javascript Tutorial Exception
Catch SyntaxError Exception in JavaScript
Catch an error in JavaScript
Catch and row exceptions in JavaScript
Catch method name not found exception in Ja...
Check the exception name and output excepti...
Create an Error with error code and message...
Throw exception out of a function in JavaSc...
Try catch user exception in JavaScript
Catch SyntaxError Exception in JavaScript
Catch an error in JavaScript
Catch and row exceptions in JavaScript
Catch method name not found exception in Ja...
Check the exception name and output excepti...
Create an Error with error code and message...
Get Exception message in JavaScript
Get Exception name in JavaScriptThrow exception out of a function in JavaSc...
Try catch user exception in JavaScript