The error objects created by constructors(Error(),  SyntaxError(), TypeError(), and others) have the following properties:

name

The name property of the constructor function that created the object; it could be the general “Error” or a more specialized constructor such as “RangeError”.

message

The string passed to the constructor when creating the object.

You can be creative when it comes to your custom error objects and use them to restore the application state back to normal.

try {

    // something bad happened, throw an error

    throw {

        name: "MyErrorType", // custom error type

        message: "oops",

        extra: "This was rather embarrassing",

        remedy: genericErrorHandler // who should handle it

    };

} catch (e) {

    // inform the user

    alert(e.message); // "oops"

    // gracefully handle the error

    e.remedy(); // calls genericErrorHandler()

}

最新文章

  1. 【集合框架】JDK1.8源码分析之HashMap & LinkedHashMap迭代器(三)
  2. [[其他教程]] 2015年最新版iOS基础视频_最适合初学者入门
  3. iOS--cocopod升级新版本
  4. 几组User-Agent
  5. ASP.Net中无刷新执行Session身份验证
  6. 【转】设计模式(十一)代理模式Proxy(结构型)
  7. 设置Git提交时不用输入用户名和密码
  8. hdoj1421(bfs)
  9. Python s12 Day2 笔记及作业
  10. ZOJ1008
  11. 第五章 服务容错保护:Spring Cloud Hystrix
  12. SEO总结
  13. [ 10.4 ]CF每日一题系列—— 486C
  14. esp32-micropython
  15. mysql root看不到mysql表
  16. Java - 15 Java 正则表达式
  17. 快速掌握和使用Flyway
  18. C#6.0语言规范(十六) 异常
  19. [转]Zend Studio中将tab转换为4个空格
  20. session使用

热门文章

  1. 我理解的Android加载器
  2. 【Android进阶系列教程】前言
  3. [Solution] ASP.NET Identity(2) 空的项目使用
  4. servlet、filter、listener、interceptor之间的区别和联系
  5. 使用Swift操作NSDate类型基础
  6. Entity FrameWork 延迟加载的本质(一)
  7. 数学 --- 高斯消元 POJ 1830
  8. JAVA - package与import解析(一)
  9. EntityFramework 6.1.2-beta2
  10. Python基础:元类