throw 抛出异常
程序员文章站
2022-05-05 08:54:21
...
<html>
<head>
<script>
var x = prompt("Enter a number between 0 and 10:"," ");
try{
if(x>10 ) throw "err1";
else if(x<0 )throw "err2";
}catch(err){
if(err=="err1") alert("Error! The value is too high");
if(err=="err2") alert("Error! The value is too low");
}
</script>
</head>
<body>
</body>
</html>
推荐阅读
-
总结十条.NET异常处理建议
-
php异常处理和错误处理区别
-
Java基础学习总结(129)——Arrays.asList得到的List进行add和remove等操作出现异常解析
-
php int处理的异常,如何解释
-
Android WindowManager$BadTokenException异常应对案例
-
Json解析异常Value of type java.lang.String cannot be converted to JSONObject
-
Json解析异常Value of type java.lang.String cannot be converted to JSONObject
-
Android WindowManager$BadTokenException异常应对案例
-
MySQL抛出Incorrect string value异常分析
-
python 异常处理总结