Repository: pantsbuild/pants

Issue:
Exception message: 'ResolveError' object has no attribute 'exc'
Pants 1.4.0.dev7

When running pants I get the error:
```
Exception caught: (<type 'exceptions.AttributeError'>)

Exception message: 'ResolveError' object has no attribute 'exc'
```

I'm pretty sure it's because I have a bad path in one of my BUILD files but it would be nice to get a bit more information from the exception - ideally exactly what is causing it but at least the BUILD file that's failing.

EDIT:
In my case this was caused by a bad path in a Java library dependency:
```
java_library(
    dependencies = ["this/didnt/exist"]
)
```


Discussion:
Thanks for the EDIT @jebbench - that helps. Could you also re-run after adding this to your pants.ini?:
```ini
[GLOBAL]
print_exception_stacktrace: True
```

Alternatively, `PANTS_PRINT_EXCEPTION_STACKTRACE=True ./pants ...` or `./pants --print-exception-stacktrace ...`.
```
Exception caught: (<class 'pants.build_graph.address_lookup_error.AddressLookupError'>)                                                                                                                                                                                        
  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/bin/pants", line 11, in <module>                                                                                                                                                                     
    sys.exit(main())                                                                                                                                                                                                                                                           
  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/local/lib/python2.7/site-packages/pants/bin/pants_loader.py", line 69, in main                                                                                                                       
    PantsLoader.run()                                                                                                                                                                                                                                                          
  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/local/lib/python2.7/site-packages/pants/bin/pants_loader.py", line 65, in run                                                                                                                        
    cls.load_and_execute(entrypoint)                                                                                                                                                                                                                                           
  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/local/lib/python2.7/site-packages/pants/bin/pants_loader.py", line 58, in load_and_execute                                                                                                           
    entrypoint_main()                                                                                                                                                                                                                                                          
  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/local/lib/python2.7/site-packages/pants/bin/pants_exe.py", line 26, in main                                                                                                                          
    PantsRunner(exiter).run()                                                                                                                                                                                                                                                  
  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/local/lib/python2.7/site-packages/pants/bin/pants_runner.py", line 57, in run
    options_bootstrapper=options_bootstrapper)
  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/local/lib/python2.7/site-packages/pants/bin/pants_runner.py", line 46, in _run
    return LocalPantsRunner(exiter, args, env, options_bootstrapper=options_bootstrapper).run()
  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/local/lib/python2.7/site-packages/pants/bin/local_pants_runner.py", line 37, in run
    self._run()
  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/local/lib/python2.7/site-packages/pants/bin/local_pants_runner.py", line 77, in _run
    self._exiter).setup()
  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/local/lib/python2.7/site-packages/pants/bin/goal_runner.py", line 198, in setup
    goals, context = self._setup_context(pantsd_launcher)
  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/local/lib/python2.7/site-packages/pants/bin/goal_runner.py", line 170, in _setup_context
    self._global_options.subproject_roots,
  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/local/lib/python2.7/site-packages/pants/bin/goal_runner.py", line 112, in _init_graph
    graph, address_mapper = graph_helper.create_build_graph(target_roots, self._root_dir)
  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/local/lib/python2.7/site-packages/pants/bin/engine_initializer.py", line 99, in create_build_graph
    for _ in graph.inject_specs_closure(target_roots.as_specs()):
  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/local/lib/python2.7/site-packages/pants/engine/legacy/graph.py", line 227, in inject_specs_closure
    for address in self._inject(specs):
  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/local/lib/python2.7/site-packages/pants/engine/legacy/graph.py", line 246, in _inject
    'Build graph construction failed: {} {}'.format(type(e).__name__, str(e))

Exception message: Build graph construction failed: ExecutionError Received unexpected Throw state(s):
Computing Select(DescendantAddresses(directory=u''), =Collection.of(HydratedTarget))
  Computing Task(<function transitive_hydrated_targets at 0x7f09d27f05f0>, DescendantAddresses(directory=u''), =Collection.of(HydratedTarget))
    Computing TransitiveDependencies( =HydratedTarget, =BuildFileAddresses)
      Computing Task(<function hydrate_target at 0x7f09d27f0668>, ervices/libraries/configuration:configuration, =HydratedTarget)
        Computing Task(<function hydrate_struct at 0x7f09d2b926e0>, ervices/libraries/configuration:configuration, =(symbol table types))
          Computing Task(<function resolve_unhydrated_struct at 0x7f09d2b92758>, ervices/libraries/configuration:configuration, =UnhydratedStruct)
            Computing Task(<function parse_address_family at 0x7f09d2b9fde8>, Dir(path='ervices/libraries/configuration'), =AddressFamily)
              Throw(Directory "Dir(path='ervices/libraries/configuration')" does not contain build files.)
                Traceback (most recent call last):
                  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/local/lib/python2.7/site-packages/pants/engine/subsystem/native.py", line 404, in extern_invoke_runnable
                    val = runnable(*args)
                  File "/home/jbench/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0.dev7/local/lib/python2.7/site-packages/pants/engine/build_files.py", line 75, in parse_address_family
                    raise ResolveError('Directory "{}" does not contain build files.'.format(path))
                ResolveError: Directory "Dir(path='ervices/libraries/configuration')" does not contain build files.
```
Aha, the error occurs specifically when an `:` or `::` address selector is used in combination with a mis-spelled dep. If a target with a bad dep is directly addressed from the command line, a reasonable error like the expanded one you pasted above is produced instead.

Resolving patch:
diff --git a/src/python/pants/engine/legacy/graph.py b/src/python/pants/engine/legacy/graph.py
--- a/src/python/pants/engine/legacy/graph.py
+++ b/src/python/pants/engine/legacy/graph.py
@@ -240,7 +240,7 @@ def _inject(self, subjects):
                                                          subjects)
     except ResolveError as e:
       # NB: ResolveError means that a target was not found, which is a common user facing error.
-      raise AddressLookupError(str(e.exc))
+      raise AddressLookupError(str(e))
     except Exception as e:
       raise AddressLookupError(
         'Build graph construction failed: {} {}'.format(type(e).__name__, str(e))


Test patch: