Jump to content
elecstorm

Catch Mantra Error

Recommended Posts

Hi! Is there a way to catch Mantra error in python script?

I want to implement something like this:
hou.hipFile.load(hipPath)
try:
    hou.node("/out/mantra").render((1, 1, 1))
except error:
    #launch manta again or something else...
hou.hipFile.clear()
print "Frame " + str(1) + " was rendered"
Edited by elecstorm

Share this post


Link to post
Share on other sites

Ok, I found this way:

    try:
        hou.node("/out/mantra1").render((1,1,1))
    except hou.Error, ex:
        print ex.instanceMessage()

It works in the python shell, I have not tested it with the hython. But I don't understand this exception (I found it somewhere):

except hou.Error, ex

"hou.Error, ex" - It's not definition (because of comma). So, what is it?

Edited by elecstorm

Share this post


Link to post
Share on other sites
Guest mantragora

Comma is old way of storing info returned from exception as variable that you can access. Use 'as' instead of comma for future proof way.

  • Like 1

Share this post


Link to post
Share on other sites

Comma is old way of storing info returned from exception as variable that you can access. Use 'as' instead of comma for future proof way.

Ok, thank you!

 

I checked script with hython - it works.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×