ジャンプ先: 概要. 戻り値. キーワード. 関連. フラグ. Python 例.
error([showLineNumber=boolean])
注: オブジェクトの名前と引数を表す文字列は、カンマで区切る必要があります。これはシノプシスに示されていません。
error は、取り消し不可能、照会不可能、および 編集不可能 です。
error コマンドは、ユーザが自分で記述したスクリプトからエラー メッセージを出力し、ランタイム エラーが発生した場合の実行を制御できるように用意されています。 文字列引数は、// で囲まれたエラー メッセージを前につけた後、コマンド ウィンドウに表示されます(またはバッチ モードで実行した場合、stdout)。 error コマンドは、実行してエラーを出力して終了します。error はコール チェーンを通して伝播するため、error を使用することは例外を引き起こすことと同じです。catch を使用してコール側からのエラーを処理することができます。実行を終了したくない場合、代わりに warning コマンドを使用するとよいでしょう。なし
| ロング ネーム(ショート ネーム) | 引数タイプ | プロパティ | ||
|---|---|---|---|---|
showLineNumber(sl)
|
boolean
|
|
||
|
||||
import maya.cmds as cmds
import maya.cmds as cmds
def lightError():
l = cmds.ls( lights=True )
if len(l) == 0:
cmds.error( "No Lights" )
lightError()
# The above will produce the following output and raise a RuntimeError
# exception from the script containing it:
#
# # Error: No Lights #
#
# If the option to display line numbers or the stack trace is turned on
# the following output will be produced and the same exception raised:
#
# # Error: line 13 of 'lightError' in '<maya console'>: No Lights #
#