• Error原生类型


    •表示错误对象
    –EvalError, URIError, RangeError, etc.
    •捕获方式:
    –try { …throw new Error(…) } catch(e) { … }
    –理论上可以throw出任意对象
    •Error对象IE和FireFox公有属性
    –message:错误信息


    Error浏览器特定属性
    •IE:
    –description:同message属性
    –number:错误编号,只有脚本引擎抛出的错误才有该属性
    •FireFox:
    –fileName:创建错误的文件
    –lineNumber:创建错误对象的行号
    –stack:创建错误时的堆栈信息


    html
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        
    <title>Native Error Type</title>
        
    <script language="javascript" type="text/javascript" src="Error.js"></script>
    </head>
    <body>
        
    <script language="javascript" type="text/javascript">
            
    try
            {
                throwError();
            }
            
    catch(e)
            {
                var errorMsg 
    = ("Message: " + e.message + "\n");
                
                
    if (!e.stack) // IE
                {
                    errorMsg 
    += ("Description: " + e.description + "\n");
                    errorMsg 
    += ("Number: " + e.number);
                }
                
    else
                {
                    errorMsg 
    += ("Line Number: " + e.lineNumber + "\n");
                    errorMsg 
    += ("File Name: " + e.fileName + "\n\n");
                    errorMsg 
    += ("Stack Trace:\n" + e.stack);
                }
                
                alert(errorMsg);
            }
        
    </script>
    </body>
    </html>

    Error.js
    function throwError()
    {
        
    throw new Error("Custom Error");
    }

    function getNiceError()
    {
        var e 
    = Error.create("Error Message",
            {customMessage : 
    "Custom Message"});
        
        e.popStackFrame();
        
    return e;
    }
  • 相关阅读:
    使用C#代码审批/转签K2 Blackpearl流程
    K2 K2Blackpearl安装步骤详解(服务端)
    部署K2 Blackpearl流程时出错(由于目标计算机积极拒绝,无法连接)
    部署K2 Blackpearl流程时出错(与基础事务管理器的通信失败或Communication with the underlying transaction manager has failed.
    解析AFNetWorking 网络框架(二)
    python学习——练习题(5)
    python学习——练习题(4)
    python学习——练习题(3)
    python学习——练习题(2)
    python学习——练习题(1)
  • 原文地址:https://www.cnblogs.com/timy/p/1181428.html
Copyright © 2020-2023  润新知