kInvalidParameter except catching

16 views
Skip to first unread message

Andres Weber

unread,
Mar 1, 2017, 4:52:27 PM3/1/17
to Python Programming for Autodesk Maya
So I have been trying to google it to no avail...probably just haven't figured out the magical one word I haven't thought of, but I was trying to write some API 2.0 code and couldn't figure out how to catch kInvalidParameter errors properly instead of just doing broad excepts which are obviously pretty opaque sometimes.  Any info about which module contains these errors?

Michael Boon

unread,
Mar 1, 2017, 5:54:40 PM3/1/17
to Python Programming for Autodesk Maya
FWIW I've had a similar experience. In the past I've caught a kInvalidParameter using RuntimeError, which isn't ideal but it was all I could find at the time. My usage was calling MFnMesh functions on a MFnMesh that I had initialised using an MObject instead of a dag path. Once I realised my mistake, I didn't need to catch it anymore.

Andres Weber

unread,
Mar 1, 2017, 9:06:27 PM3/1/17
to Python Programming for Autodesk Maya
Yeah it's definitely easier to accurately filter what the inputs are, but I like to make my functions as robust and error catching as possible.  I guess RuntimeError will do for now, thanks for the suggestion!
Reply all
Reply to author
Forward
0 new messages