pymel.core.system.error

error(*args, **kwargs)

The error command is provided so that the user can issue error messages from his/her scripts and control execution in the event of runtime errors. The string argument is displayed in the command window (or stdout if running in batch mode) after being prefixed with an error message heading and surrounded by //. The error command also causes execution to terminate with an error. Using error is like raising an exception because the error will propagate up through the call chain. You can use catch to handle the error from the caller side. If you don’t want execution to end, then you probably want to use the warning command instead.

Flags:
Long name (short name) Argument Types Properties
showLineNumber (sl) bool ../../../_images/create.gif
 

Obsolete. Will be deleted in the next version of Maya. Use the checkbox in the script editor that enables line number display instead.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list.

Derived from mel command maya.cmds.error

Example:

import pymel.core as pm

import maya.cmds as cmds

import maya.cmds as cmds
def lightError():
    l = pm.ls( lights=True )
    if len(l) == 0:
        pm.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 #
#

Previous topic

pymel.core.system.dynamicLoad

Next topic

pymel.core.system.exportAll

Core

Core Modules

Other Modules

This Page