how to use error in html code example
Example 1: javascript try catch
<html>
<head>Exception Handling</head>
<body>
<script>
try {
throw new Error('This is the throw keyword'); //user-defined throw statement.
}
catch (e) {
document.write(e.message); // This will generate an error message
}
</script>
</body>
</html>
Example 2: try catch error
try {
console.log('hello');
}
catch (e){
}