catch only suppresses errors, catchQuiet suppress errors and warnings. But I 
don't think you can extract the message from them?

I haven't tested this but the only way that I can think of getting hold of a 
warning message is through altering the GUI logger and log handler that maya 
uses to output to the script editor. The MayaGuiLogHandler class in maya.utils 
passes messages to OpenMaya.MGlobal.displayError/Warning/Info for different 
types of logs.

As a way to get more control over how exceptions are handled (like having 
exceptions that are raised in your scripts send you an email), you can also 
customize error outputs in Maya by overriding maya.utils._guiExceptHook. 
Example by Nathan Horne: http://nathanhorne.com/?p=245

On Wednesday, March 13, 2013 11:53:18 AM UTC-7, Justin Israel wrote:
> Does catch actually catch warning, or just the errors? Warnings are kind of 
> like print statements that trigger some UI color coding. If catch can see 
> them then that's probably the way, since they aren't exceptions. 
> 
> 
> On Mar 14, 2013 7:41 AM, "Jesse Capper"  wrote:
> 
> You can use try/except statements to catch Maya errors. For example:
> 
> 
> 
> cmds.select(cl=True)
> 
> try:
> 
>     cmds.extrude()
> 
> except Exception, e:
> 
>     print "There was an error and it said", e
> 
> 
> 
> I don't know of any way to tell if a warning is raised, only that you can 
> catch (suppress) them using mel.eval('catchQuiet(command)').
> 
> 
> 
> On Wednesday, March 13, 2013 9:56:24 AM UTC-7, illunara wrote:
> 
> > Hi everybody
> 
> > I wonder if i can catch a maya error(or warning) before it happen? Lets say 
> > like this, i would like to test if an user's action will lead to an error 
> > or not.
> 
> > Thanks :D
> 
> 
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Python Programming for Autodesk Maya" group.
> 
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> 
> To post to this group, send email to [email protected].
> 
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to