On this page | |
Inheritence |
|
概要
This is different from other exceptions that are typically raised by the system when something goes wrong, such as invalid inputs to a method call. This is an exception you, the author of a Python SOP, or Python Object, or Python LOP, etc., raise in the node’s implementation script to set messages/warnings/errors on the node.
Errors, warnings, and messages are part of a node’s user interface. They show up in the network editor, parameter editor, and info window.
-
Errors signal to the node’s user that the node has encountered an error. For example, invalid inputs or parameter values.
-
Warnings signal that the node was able to cook, but there was a problem the user might want to check. For example, a missing texture.
See Writing Python SOPs for more information.
Tip
To mark the node with a warning instead of an error, raise hou.NodeWarning instead.
Example
If you're writing a Python SOP, you might depend on information in an external file, specified by a parameter on the node:
thisnode = hou.pwd() filepath = thisnode.parm("file").evalAsString() content = hou.readFile(filepath) # ...
If the file doesn’t exist, you should raise this exception to signal to Houdini that the node could not cook, and specify an error message to help the user correct the problem:
import os.path thisnode = hou.pwd() filepath = thisnode.parm("file").evalAsString() if not os.path.exists(filepath): raise hou.NodeError("File {} does not exist".format(filepath)) content = hou.readFile() # ...
Methods from hou.Error
description()
→ str
例外のクラスの説明を返します。この説明は、例外インスタンスには関係ありません。
exceptionTypeName()
→ str
例外タイプの名前を返します。
異なるサブクラスのhou.Errorのインスタンスは、異なる名前を返します。
基本クラスのインスタンスは、"Error"
を返します。
str(e.__class__)
を使用することで、そのサブクラスの名前を取得することもできます。
instanceMessage()
→ str
例外インスタンス固有のメッセージを返します。
See also |