Javascript Exception
来源:互联网 发布:烟台java培训班哪个好 编辑:程序博客网 时间:2024/06/11 08:21
The throw statement interrupts execution of the function. It should be given an exception object containing a name property that identifies the type of the exception, and a descriptive message property. You can also add other properties.
function UserException(message) { this.message = message; this.name = "UserException";}function getMonthName(mo) { mo = mo-1; // Adjust month number for array index (1=Jan, 12=Dec) var months = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); if (months[mo] !== undefined) { return months[mo]; } else { throw new UserException("InvalidMonthNo"); }} try { // statements to try var myMonth = 15; // 15 is out of bound to raise the exception monthName = getMonthName(myMonth);} catch (e) { monthName = "unknown"; logMyErrors(e.message, e.name); // pass exception object to err handler}
- Javascript Exception
- JavaScript的Exception处理(try...catch...finally)
- C++、Java、JavaScript中的异常处理(Exception)
- Exception
- Exception
- Exception
- exception
- Exception
- Exception
- Exception
- exception
- Exception
- Exception
- Exception
- Exception
- exception
- exception
- exception
- Spring-MVC入门(一):入门实例
- LinkedIn用一幅图告诉你:工程师最想去的10家硅谷创业公司
- Javascript call and apply
- 通过金矿模型介绍动态规划
- Java环境变量配置
- Javascript Exception
- Javascript OOP augmenting with prototype
- 背包总结
- QWT在win7下的安装说明
- 使用QWT产生error LNK2001的原因及解决方案
- Javascript Closure
- 集训第三周
- 黑马程序员——集合学习日志
- YouTube视频播放器采用了HTML5