From 22b7dc4473b1a293de55199ff7aa2ddce5e28827 Mon Sep 17 00:00:00 2001 From: Kristina Chodorow Date: Thu, 5 May 2016 19:06:12 +0000 Subject: Catch package lookup exceptions during AST lookup Noticed this while debugging #1228. Referencing a non-existent (BuildFileNotFoundException) package would print "Loading failed; build aborted" with no error message about what had actually gone wrong. -- MOS_MIGRATED_REVID=121602225 --- .../devtools/build/lib/skyframe/ASTFileLookupFunction.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java') diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java index e0bafdfd46..201891939a 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java @@ -15,6 +15,7 @@ package com.google.devtools.build.lib.skyframe; import com.google.devtools.build.lib.cmdline.Label; +import com.google.devtools.build.lib.packages.BuildFileNotFoundException; import com.google.devtools.build.lib.packages.RuleClassProvider; import com.google.devtools.build.lib.syntax.BuildFileAST; import com.google.devtools.build.lib.syntax.Mutability; @@ -60,7 +61,15 @@ public class ASTFileLookupFunction implements SkyFunction { // SkyKey pkgSkyKey = PackageLookupValue.key(fileLabel.getPackageIdentifier()); PackageLookupValue pkgLookupValue = null; - pkgLookupValue = (PackageLookupValue) env.getValue(pkgSkyKey); + try { + pkgLookupValue = (PackageLookupValue) env.getValueOrThrow( + pkgSkyKey, BuildFileNotFoundException.class, InconsistentFilesystemException.class); + } catch (BuildFileNotFoundException e) { + throw new ASTLookupFunctionException( + new ErrorReadingSkylarkExtensionException(e), Transience.PERSISTENT); + } catch (InconsistentFilesystemException e) { + throw new ASTLookupFunctionException(e, Transience.PERSISTENT); + } if (pkgLookupValue == null) { return null; } -- cgit v1.2.3