Autodesk / Autodesk/maya-usd

Raise more informational error from errors in custom Python chaser

Open
#3,314 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Wolfram Language
Stars
905
Forks
223
Avg merge
2d 9h
Merged PRs (30d)
17

Description

**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:
```python
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`:

```python
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 "", line 14, in
# # File "", 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](https://github.com/Autodesk/maya-usd/issues/2365#issuecomment-1313594168) and [here](https://github.com/Autodesk/maya-usd/issues/2365#issuecomment-1315326249).

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the failure with the custom ExportChaser examples and the mayaUSDExport entry point. Inspect how exceptions from PostExport are surfaced, including the case where PostExport does not return True. Done means developers receive an informative error identifying the Python chaser and its source traceback rather than only a generic RuntimeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.