自定义错误throw
2024-09-05 04:27:51
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>自定义错误throw</title>
<!--
throw a;
解读:
抛出错误,并自定义错误消息a,a就是发生错误后的消息提示
可使用catch(b)捕获错误信息b,b就是自定义错误的名字,也可以称为容纳错误的对象 切记:当生成错误时,JavaScript实际上会创建带有两个属性的Error对象:name和message。
-->
</head>
<body>
<script>
var a=1;
try{
throw "我是错误提示";//自定义error massage
}
catch (b){//catch()捕获error name=b
console.log(b);//b容纳了throw定义的error massage
}
</script>
</body>
</html>
最新文章
- [BZOJ4198][Noi2015]荷马史诗
- js实现快速排序
- Warning: Null value is eliminated by an aggregate or other SET operation.
- lodash常用方法1--查询
- android开发 两张bitmap图片合成一张图片
- PAT 1017
- System Operations on AWS - Lab 2 - Configuring VPC
- PL/SQL 包头和包体
- DIV+CSS 让同一行的图片和文字对齐
- Linux(centos5.0+)unison+inotify-tools触发式双向自动同步
- netty&mdash;&mdash;私有协议栈开发案例
- sed 实践案例 (不定期更新)
- 三十分钟学完Vue
- CF 634A Island Puzzle
- C#-----类FileStream的使用
- centos7 pgpool+postgresql
- JS删除String里某个字符的方法
- [转]一个CMake编译问题的解决过程
- 基于asp.net mvc的近乎产品开发培训课程(第三讲)
- jenkins 基本插件
热门文章
- 缓存利器之Ehcache
- 【坑】Mybatis 多次逆向工程生成mapper文件
- 安卓版 WPS 使用电脑字体、安卓版 WPS 添加字体、安卓 WPS 无法显示文档真实字体(24)
- LC 21. Merge Two Sorted Lists
- sql注入测试(3)---现象分析
- python运行报错:cannot import name &#39;InteractiveConsole&#39;
- 编程模型&;编程思想
- C++ raw string literal
- html5+css3 快速学习
- hive 存储格式对比