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