From 0a4c6e4608121eb1ef3f62dda5bddc8a9fed308d Mon Sep 17 00:00:00 2001 From: Janak Ramakrishnan Date: Thu, 17 Sep 2015 00:37:58 +0000 Subject: Stop throwing an exception if a Package was successfully created but contains errors. Instead, require callers to process the package and throw if they need to. This allows us to avoid embedding a Package in an exception, which is icky. This also allows us to remove Package#containsTemporaryErrors. Most callers' changes are fairly straightforward. The exception is EnvironmentBackedRecursivePackageProvider, which cannot throw an exception of its own in case of a package with errors (because it doesn't do that in keep_going mode), but whose request for a package with errors *should* shut down the build in case of nokeep_going mode. To do this in Skyframe, we have a new PackageErrorFunction which is to be called only in this situation, and will unconditionally throw. EnvironmentBackedRecursivePackageProvider can then catch this exception and continue on as usual, except that the exception will shut down the thread pool in a nokeep_going build. -- MOS_MIGRATED_REVID=103247761 --- .../SkyframePackageLoaderWithValueEnvironment.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/SkyframePackageLoaderWithValueEnvironment.java') diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframePackageLoaderWithValueEnvironment.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframePackageLoaderWithValueEnvironment.java index 80ccb1380e..b7d94e7dd7 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframePackageLoaderWithValueEnvironment.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframePackageLoaderWithValueEnvironment.java @@ -46,7 +46,9 @@ class SkyframePackageLoaderWithValueEnvironment implements this.env = env; } - private Package getPackage(PackageIdentifier pkgIdentifier) throws NoSuchPackageException{ + @Override + public Package getLoadedPackage(final PackageIdentifier pkgIdentifier) + throws NoSuchPackageException { SkyKey key = PackageValue.key(pkgIdentifier); PackageValue value = (PackageValue) env.getValueOrThrow(key, NoSuchPackageException.class); if (value != null) { @@ -55,19 +57,6 @@ class SkyframePackageLoaderWithValueEnvironment implements return null; } - @Override - public Package getLoadedPackage(final PackageIdentifier pkgIdentifier) - throws NoSuchPackageException { - try { - return getPackage(pkgIdentifier); - } catch (NoSuchPackageException e) { - if (e.getPackage() != null) { - return e.getPackage(); - } - throw e; - } - } - @Override public Target getLoadedTarget(Label label) throws NoSuchPackageException, NoSuchTargetException { -- cgit v1.2.3