Print the traceback when there is a problem loading or calling a backend module

Review Request #1582 - Created Jan. 8, 2015 and submitted

Information
Eric Ayers
pants
zundel/traceback-for-extension-load-failure
921
85ac4cc...
Reviewers
pants-reviews
patricklaw
Print the traceback when there is a problem loading or calling a backend module

I have a bug in my backend right now. It was failing with:

devpants compile src/ --print-exception-stacktrace
*** Running pants in dev mode from /Users/zundel/Src/pants/src/python/pants/bin/pants_exe.py ***

Exception caught:
  File "/Users/zundel/Src/pants/src/python/pants/bin/pants_exe.py", line 71, in <module>
    main()
  File "/Users/zundel/Src/pants/src/python/pants/bin/pants_exe.py", line 66, in main
    _run()
  File "/Users/zundel/Src/pants/src/python/pants/bin/pants_exe.py", line 60, in _run
    goal_runner.setup()
  File "/Users/zundel/Src/pants/src/python/pants/bin/goal_runner.py", line 66, in setup
    build_configuration = load_plugins_and_backends(plugins, backend_packages)
  File "/Users/zundel/Src/pants/src/python/pants/base/extension_loader.py", line 30, in load_plugins_and_backends
    load_build_configuration_from_source(build_configuration, additional_backends=backends or [])
  File "/Users/zundel/Src/pants/src/python/pants/base/extension_loader.py", line 104, in load_build_configuration_from_source
    load_backend(build_configuration, backend_package)
  File "/Users/zundel/Src/pants/src/python/pants/base/extension_loader.py", line 126, in load_backend
    .format(backend=backend_module, error=e))

Exception message: Failed to load the pants.backend.core.register backend: cannot import name SourceSet

That's not much help. To debug it I had to comment out the exception handling in extension_loader.py.

After this change, it prints the (real) cause out (circular import in my case)

Traceback (most recent call last):
  File "/Users/zundel/Src/pants/src/python/pants/base/extension_loader.py", line 122, in load_backend
    'register_goals'])
  File "/Users/zundel/Src/pants/src/python/pants/backend/core/register.py", line 12, in <module>
    from pants.backend.core.targets.doc import Page, Wiki, WikiArtifact
  File "/Users/zundel/Src/pants/src/python/pants/backend/core/targets/doc.py", line 11, in <module>
    from pants.backend.core.targets.source_set import SourceSet
  File "/Users/zundel/Src/pants/src/python/pants/backend/core/targets/source_set.py", line 14, in <module>
    from pants.backend.jvm.targets.jar_source_set import JarSourceSet
  File "/Users/zundel/Src/pants/src/python/pants/backend/jvm/targets/jar_source_set.py", line 11, in <module>
    from pants.backend.core.targets.source_set import SourceSet
ImportError: cannot import name SourceSet
Patrick Lawson
Eric Ayers
Review request changed

Status: Closed (submitted)

Change Summary:

commit 2ab755f

Loading...