Thanks, Jesse! Not to beat a dead horse here, but for the sake of posterity:
Without stack trace enabled, Maya 2011+ won't print a custom exception
message for a derived class, but *WILL* print it if you just call the base
class. For example:
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
will print
# Error: SelectionError: file <maya console> line 1: #
However, just doing this
try: raise Exception('You selected too many objects')
except: raise
will print this
# Error: Exception: file <maya console> line 1: You selected too many
objects #
On Thu, Mar 24, 2011 at 7:55 PM, Jesse Kretschmer <[email protected]> wrote:
>
>> 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?*
>>
>
>
> Are you running Maya 2011? If so make sure that *Show Stack Trace* is
> enabled in the *Script Editor*. It is under the *History *menu.
>
> Also you could try printing the error the maya way:
> import maya.OpenMaya
> OpenMaya.MGlobal.displayError("String")
>
> good luck.
>
--
http://groups.google.com/group/python_inside_maya