If you enter the following code in Maya:
try:
foo = 1/0
except: raise
You'll get the following output:
# Error: ZeroDivisionError: file <maya console> line 2: integer division or
modulo by zero #
In IDLE, you'll get this:
Traceback (most recent call last): File "<pyshell#1>", line 2, in <module>
foo = 1/0 ZeroDivisionError: integer division or modulo by zero
Great! Both cases tell me where the error is, *and something meaningful
about it** *("integer division or modulo by zero"). So now I want to make a
custom exception, so that I can give it its own unique, useful message. I
try this:
class SelectionError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return self.value
try:
raise SelectionError('You selected too many objects')
except: raise
IDLE will print:
Traceback (most recent call last): File "<pyshell#5>", line 2, in <module>
raise SelectionError('You selected too many objects') SelectionError: You
selected too many objects
But Maya will print:
# Error: SelectionError: file <maya console> line 2: #
*Am I missing something really basic here, or can Maya seriously not print
custom exception messages to the console?*
--
http://groups.google.com/group/python_inside_maya