sourCEntral - mobile manpages

pdf

bgerror

______________________________________________________________________________

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

pdf