カスタム *error* ハンドラ内での command 関数の使用を示すエラー処理関数。
サポートされているプラットフォーム: Windows および Mac OS
(*push-error-using-command*)
引数はありません。
タイプ: T
値 T が返されます。
*push-error-using-command* に対する呼び出しは、command 関数の使用を含むカスタム *error* ハンドラ関数を定義した後に実行する必要があります。
*push-error-using-command* を使用する場合、カスタム *error* ハンドラからアクセスできるのはグローバル変数だけに制限され、エラーが発生した関数内で定義されているローカル変数にはアクセスできません。ローカル変数にアクセスする必要がある場合、command 関数のすべてのインスタンスを command-s 関数と置き換え、*push-error-using-stack* に対する呼び出しを使用します。
次に、*push-error-using-command* 関数の使用例を示します。
(defun my_err (err_msg)
(if (/= err_msg "Function cancelled")
(prompt (strcat "\nError: " err_msg))
)
(command "._undo" "_e")
(command "._U")
(setq *error* olderr)
(princ)
)
(defun myUtil (key / )
(setq olderr *error*
*error* my_err)
(*push-error-using-command*) ; Indicate use of Command function instead of Command-s
; in the custom error handler
(command "._undo" "_group") ; The following will not be executed in this sample, but is good
; framework for setting up your own error handlers
(/ 1 0) ; Call a function with incorrect values to trigger the custom error handler
; Remove when setting up your code
;; Perform your tasks here
(command "._undo" "_e")
(setq *error* olderr) ; Restore old *error* handler
(*pop-error-mode*) ; End the use of *push-error-using-command*
)
サンプル コードをロードした後、コマンド プロンプトに対して (myutil "String") と入力し、エラー ハンドラを入力します。