Updates error message when referencing the wrong path to a target in a BUILD file

When you put a bad path in target you get the error:

Exception message: BUILD file does not exist at: /Users/zundel/Src/Pants/maven_src/resource_collision/example_b/src/main/java/com/pants/exampleb

This isn't much help if you don't know where the reference came from - you'll have to grep through all your BUILD files.

This updates the message to include the referencing target in the error: 

Exception message: BUILD file does not exist at: /Users/zundel/Src/Pants/maven_src/resource_collision/example_b/src/main/java/com/pants/exampleb referenced from maven_src/resource_collision/example_a/src/main/java/com/pants/duplicatepaths/examplea:examplea


See https://github.com/pantsbuild/pants/pull/442


On Tue, Aug 5, 2014 at 6:34 PM, Garrett <notifications@github.com> wrote:

> In src/python/pants/base/build_file_parser.py:
>
> > @@ -99,7 +99,13 @@ def inject_address_closure_into_build_graph(self,
> >      if address in addresses_already_closed:
> >        return
> >
> > -    self._populate_target_proxy_transitive_closure_for_address(address)
> > +    try:
> > +      self._populate_target_proxy_transitive_closure_for_address(address)
> > +    except BuildFile.MissingBuildFileError as e:
> > +      raise BuildFile.MissingBuildFileError("{message} referenced from {spec}"
> > +                                            .format(message=e.message,
> > +                                                    spec=address.spec))
> > +
>
> I'd find this more useful if this described the full list of specs leading
> up to the error, since
> _populate_target_proxy_transitive_closure_for_address is recursive. I
> implemented it inside the method by wrapping the for-loop at the tail:
>
> try:
>   for dep_address in target_proxy.dependency_addresses(BuildFileCache.spec_path_to_build_file):
>     if dep_address not in addresses_already_closed:
>       self._populate_target_proxy_transitive_closure_for_address(dep_address,
>                                                                  addresses_already_closed)
> except Exception as err:
>   raise BuildFileParser.InvalidTargetException('Error transitively parsing {address}:\n{error}'
>       .format(address=address.spec, error=str(err)))
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/square/pants/pull/1/files#r15846616>.
>