zoukankan      html  css  js  c++  java
  • Error原生类型的扩展

    •Error.create(message, errorInfo)方法:
    –创建新的Error对象
    –将Error对象的错误信息属性设为message
    –将errorInfo上的信息附加到Error对象
    •Error.prototype.popStackFrame()方法:
    –为Error对象整理出更优雅直观的信息(lineNumber, stack)
    –对于IE无效
    –如果一个方法仅仅是返回Error对象而不是抛出对象,则在返回前应该调用该方法


    aspx
    <%@ Page Language="C#" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">

    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        
    <title>Error Type Extensions</title>
        
    <script language="javascript" type="text/javascript" src="Error.js"></script>
    </head>
    <body>
        
    <form id="form1" runat="server">
            
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
        
            please view the page 
    in FireFox
            
    <script language="javascript" type="text/javascript">
                
    try
                {
                    
    throw getNiceError();
                }
                
    catch(e)
                {
                    var errorMsg 
    = ("Message: " + e.message + "\n");
                    errorMsg 
    += ("Line Number: " + e.lineNumber + "\n");
                    errorMsg 
    += ("File Name: " + e.fileName + "\n\n");
                    errorMsg 
    += ("Stack Trace:\n" + e.stack);
                    alert(errorMsg);
                }
            
    </script>
        
    </form>
    </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;
    }
  • 相关阅读:
    串口通信(2)
    串口通信(1)
    extern关键字的使用
    volatile关键字的使用
    Uart串口与RS232串口的区别
    DSP5509的时钟发生器(翻译总结自TI官方文档)
    DSP中的cmd文件
    pragma伪指令
    在C语言中嵌入汇编语言
    another app is currently holding the yum lock;waiting for it to exit...
  • 原文地址:https://www.cnblogs.com/timy/p/1181432.html
Copyright © 2011-2022 走看看