Autodesk / maya-usd

A common USD (Universal Scene Description) plugin for Autodesk Maya
761 stars 202 forks source link

Raise more informational error from errors in custom Python chaser #3314

Open BigRoy opened 1 year ago

BigRoy commented 1 year ago

Is your feature request related to a problem? Please describe.

When an error occurs in a Python chaser the only error given is:

# Error: RuntimeError: Tf Python Exception

It'd be great if instead it could somehow provide a stack trace to the source line of code of the Python class for the tracer.

Reproducable:

import mayaUsd.lib as mayaUsdLib

class CrashChaser(mayaUsdLib.ExportChaser):
    def PostExport(self):
        raise RuntimeError("error")
        return True

mayaUsdLib.ExportChaser.Unregister(CrashChaser, "crash")
mayaUsdLib.ExportChaser.Register(CrashChaser, "crash")

from maya import cmds
cmds.loadPlugin("mayaUsdPlugin", quiet=True)
cmds.mayaUSDExport(file="E:/test.usd",
                   frameRange=(1, 5),
                   frameStride=1.0,
                   chaser=["crash"],
                   selection=True)

Similarly a confusing error is raised if e.g. PostExport method does not return True:

import mayaUsd.lib as mayaUsdLib

class CrashChaser(mayaUsdLib.ExportChaser):
    def PostExport(self):
        pass

mayaUsdLib.ExportChaser.Unregister(CrashChaser, "crash")
mayaUsdLib.ExportChaser.Register(CrashChaser, "crash")

from maya import cmds
cmds.loadPlugin("mayaUsdPlugin", quiet=True)
cmds.mayaUSDExport(file="E:/test.usd",
                   frameRange=(1, 5),
                   frameStride=1.0,
                   chaser=["crash"],
                   selection=True)

Which gives:

# # Traceback (most recent call last):
# #   File "<maya console>", line 14, in <module>
# #   File "<string>", line 2, in mayaUSDExport
# # RuntimeError: Maya command error

Describe the solution you'd like

Improve the error messages for developers so they know what's acting up and how they should continue.

Additional context

The raised errors being unclear was also mentioned here and here.

maya-usd-git-sync[bot] commented 10 months ago

Issue synced internally to EMSUSD-810