On this page | |
Inheritance |
|
Overview ¶
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
Return a description of the class of exception. The description is not related to the exception instance.
exceptionTypeName()
→ str
Return the name of the exception type. Instances of different
subclasses of hou.Error will return different names. Instances of the
base class will return "Error"
.
You can also use str(e.__class__)
to get the name of the subclass.
instanceMessage()
→ str
Return a message specific to the exception instance.
See also |