Scroll to navigation

bgerror(3tcl) Tcl Built-In Commands bgerror(3tcl)


NAME

bgerror - 為處理後臺錯誤而被呼叫的命令

總覽 SYNOPSIS

bgerror message


描述 DESCRIPTION

bgerror 命令不作為 Tcl 內建部分而存在。如果單獨的某個應用或使用者希望處理後臺錯誤,可以定義一個 bgerror 命令(例如,作為一個 Tcl 過程)。

後臺錯誤發生在事件處理器(handler)或不是由應用發起(originate)的一些其他命令中。例如,如果在執行一個用 after 命令指定的一個命令時發生了一個錯誤,那麼這就是一個後臺錯誤。對於一個非後臺錯誤,透過巢狀的 Tcl 命令求值(evaluation), 錯誤可以被簡單的向上返回,直到到達應用中的頂層程式碼;則應用可以用任何它希望的方式來報告錯誤。 當一個後臺錯誤發生時,在 Tcl 庫中終止命令解釋(unwinding ends ? 鬆開末端)並且沒有給 Tcl 用來報告錯誤明顯的途徑。

當 Tcl 檢測到一個後臺錯誤時,它儲存關於錯誤的資訊並作為一個空閒處理器而在以後呼叫 bgerror 命令。在呼叫 bgerror 之前,Tcl 把 fBerrorInfo 和 errorCode 變數的儲存成它們在錯誤發生時的值,接著用錯誤訊息作為唯一的引數來呼叫 bgerror。Tcl 假定應用已經實現了 bgerror 命令,命令以對應用有意義的方式來報告錯誤。 Tcl 在 bgerror 命令沒有生成錯誤時忽略返回的任何結果。

如果在 bgerror 命令中發生了另一個 Tcl 錯誤(例如,沒有定義 bgerror 命令)則 Tcl 透過向標準錯誤寫訊息來處理這個自身的錯誤。

在呼叫 bgerror 來處理錯誤之前如果積累了一些錯誤,將以發生的次序為每個錯誤呼叫一次 bgerror。但是,如果 bgerror 以一個 break 例外返回,則跳過所有的餘下的錯誤而不呼叫 bgerror


Tcl 沒有預設的實現 bgerror。但是,在使用 Tk 的應用中有一個預設的 bgerror 過程,它貼出(post)一個對話方塊,包含了錯誤資訊並向用戶提供一個機會來檢視顯示在什麼地方發生錯誤的棧跟蹤。 In addition to allowing the user to view the stack trace, the dialog provides an additional application configurable button which may be used, for example, to save the stack trace to a file. By default, this is the behavior associated with that button. This behavior can be redefined by setting the option database values *ErrorDialog.function.text, to specify the caption for the function button, and *ErrorDialog.function.command, to specify the command to be run. The text of the stack trace is appended to the command when it is evaluated. If either of these options is set to the empty string, then the additional button will not be displayed in the dialog.

參見 SEE ALSO

after(n), tclvars(n)

關鍵字 KEYWORDS

background error, reporting

[中文版維護人]

寒蟬退士

[中文版最新更新]

2001/06/27

《中國 Linux 論壇 man 手冊頁翻譯計劃》:

http://cmpp.linuxforum.net

本頁面中文版由中文 man 手冊頁計劃提供。
中文 man 手冊頁計劃:https://github.com/man-pages-zh/manpages-zh

7.5 Tcl