try...catch
来源:互联网 发布:ftp站点怎么绑定域名 编辑:程序博客网 时间:2024/05/16 12:36
try{} catch(e){}
一个花括号里应该是一个代码块,所以try和,catch后都有大括号.
try如果有异常,异常参数会给e.
比如
function add(a,b){
if(typeof a !=="number" || typeof b !=="number"){
throw{
name:'type error',
message:'add need number'
};
}
return a+b;
}
var try_it = function () {
try
{add("a");}
catch(e){
document.write(e.name+':'+e.message);
}
}
try_it();
这里抛出的异常会在catch里处理.
暂时发现的异常包括在try里执行出现的异常,和try里执行的函数throw的异常.
- try catch
- try{} catch{}
- try catch
- try...catch
- try{} catch(...){}
- try catch
- try-catch
- try catch
- try-catch
- try catch
- try catch
- try catch
- try catch
- try catch
- try {...} catch (){....}
- try{} catch{}
- try catch
- Try catch
- java concurrent in practise 笔记
- 取消Windows2003关机事件跟踪
- ABAP 如何显示图片
- 都是“引用”惹得祸!
- javascript递归
- try...catch
- 我在指挥他们呢!
- swt封装包
- MySQL int(11) 和 int(3) 在数据库里存储一样的结果
- C++虚函数表解析(转) ——写的真不错,忍不住转了
- 在Eclipse中安装SWT插件
- c#中PROCESS的用法
- 儿子能记住我一月前说的事情!
- VS2010将序列号内嵌到安装程序的方法