
- Rexx 教程
- Rexx - 首頁
- Rexx - 概述
- Rexx - 環境
- Rexx - 安裝
- Rexx - 外掛安裝
- Rexx - 基本語法
- Rexx - 資料型別
- Rexx - 變數
- Rexx - 運算子
- Rexx - 陣列
- Rexx - 迴圈
- Rexx - 決策
- Rexx - 數字
- Rexx - 字串
- Rexx - 函式
- Rexx - 棧
- Rexx - 檔案 I/O
- Rexx - 檔案函式
- Rexx - 子程式
- Rexx - 內建函式
- Rexx - 系統命令
- Rexx - XML
- Rexx - Regina
- Rexx - 解析
- Rexx - 訊號
- Rexx - 除錯
- Rexx - 錯誤處理
- Rexx - 面向物件
- Rexx - 可移植性
- Rexx - 擴充套件函式
- Rexx - 指令
- Rexx - 實現
- Rexx - Netrexx
- Rexx - Brexx
- Rexx - 資料庫
- 手持裝置和嵌入式
- Rexx - 效能
- Rexx - 最佳程式設計實踐
- Rexx - 圖形使用者介面
- Rexx - Reginald
- Rexx - Web 程式設計
- Rexx 有用資源
- Rexx - 快速指南
- Rexx - 有用資源
- Rexx - 討論
Rexx - 錯誤處理
Rexx 也有能力像其他程式語言一樣處理錯誤。
以下是 Rexx 中的一些常見錯誤情況。
ERROR − 當傳送到作業系統的命令導致錯誤時,將引發此事件。
FAILURE − 當傳送到作業系統的命令導致失敗時,將引發此事件。
HALT − 通常在某個操作依賴於另一個操作時引發。例如,如果 I/O 操作因任何原因被停止。
NOVALUE − 當變數未賦值時,將引發此事件。
NOTREADY − 由任何未準備好接受任何操作的 I/O 裝置引發。
SYNTAX − 如果程式碼中存在任何語法錯誤,將引發此事件。
LOSTDIGITS − 當算術運算在操作過程中導致數字丟失時,將引發此事件。
捕獲錯誤
可以使用 signal 命令捕獲錯誤。讓我們看一下它的語法和示例。
語法
signal on [Errorcondition]
其中,
Errorcondition − 上述錯誤條件。
示例
讓我們看一個示例。
/* Main program */ signal on error signal on failure signal on syntax signal on novalue beep(1) signal off error signal off failure signal off syntax signal off novalue exit 0 error: failure: syntax: novalue: say 'An error has occured'
在上面的示例中,我們首先開啟錯誤訊號。然後我們新增一個會導致錯誤的語句。然後我們使用錯誤捕獲標籤來顯示自定義錯誤訊息。
上述程式的輸出將如下所示。
An error has occurred.
以下程式顯示了錯誤程式碼的示例。
/* Main program */ signal on error signal on failure signal on syntax signal on novalue beep(1) exit 0 error: failure: syntax: novalue: say 'An error has occured' say rc say signal
上述程式的輸出將如下所示。
An error has occured 40 6
廣告