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 an error instead of a warning, raise hou.NodeError instead.
Note
Raise a warning exception at the end of the script, so the node script otherwise completes cooking.
Example ¶
If you're writing a Python SOP, you might use the content of an external file (referenced in a parameter on the node), even though the node can work without the file:
import os.path thisnode = hou.pwd() filepath = thisnode.parm("file").evalAsString() content = hou.readFile() if content: # Use the file contents # ... # Continue script operation # ... # At the end of the script, raise any warning that might have # come up during the script if not content: raise NodeWarning("The texture file is missing or empty")
¶
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 |