<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [TOC] ## 斷言 assert ``` local function add(a,b) assert(type(a) == "number", "a 不是一個數字") assert(type(b) == "number", "b 不是一個數字") return a+b end add(10) ``` ## 錯誤 error ``` error (message [, level]) ``` 功能:終止正在執行的函數,并返回message的內容作為錯誤信息(error函數永遠都不會返回) 通常情況下,error會附加一些錯誤位置的信息到message頭部。 Level參數指示獲得錯誤的位置: * Level=1\[默認\]:為調用error位置(文件+行號) * Level=2:指出哪個調用error的函數的函數 * Level=0:不添加錯誤位置信息 示例 ``` local function add(a,b) if type(a) ~= "number" then error("a not a number",2) end if type(b) ~= "number" then error("b not a number",2) end return a+b end add(10,"123") ``` ## pcall 和 xpcall、debug pcall ``` function add(a, b) if type(a) ~= "number" then error("a is not a number") end if type(b) ~= "number" then error("b is not a number") end return a+b end if pcall(add, 1,"2") then print("success") else print("have error") end // have error ``` xpcall ``` function add(a, b) if type(a) ~= "number" then error("a is not a number") end if type(b) ~= "number" then error("b is not a number") end return a+b end function myerrorhandle(err) print("error:",err) end status = xpcall(function() add(1,"2") end,myerrorhandle) print(status) -- error: demo1.lua:12: b is not a number -- false ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看