Skip to content

Commit

Permalink
Create non fatal exception when errors are not detailed with a Failur…
Browse files Browse the repository at this point in the history
…eDetail.

PiperOrigin-RevId: 447471364
  • Loading branch information
zhengwei143 authored and copybara-github committed May 9, 2022
1 parent b2604f0 commit 74fff55
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package com.google.devtools.build.lib.query2.query;

import com.google.devtools.build.lib.bugreport.BugReport;
import com.google.devtools.build.lib.bugreport.BugReport.NonFatalBugReport;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.concurrent.ThreadSafety;
import com.google.devtools.build.lib.packages.Attribute;
Expand Down Expand Up @@ -59,7 +60,7 @@ class TargetEdgeErrorObserver implements TargetEdgeObserver {
@Override
public void missingEdge(Target target, Label label, NoSuchThingException e) {
hasErrors = true;
errorCode.compareAndSet(/*expect=*/ null, /*update=*/ e.getDetailedExitCode());
errorCode.compareAndSet(/*expectedValue=*/ null, /*newValue=*/ e.getDetailedExitCode());
}

/**
Expand Down Expand Up @@ -93,11 +94,18 @@ public void node(Target node) {
this.hasErrors = true;
FailureDetail failureDetail = node.getPackage().getFailureDetail();
if (failureDetail != null) {
errorCode.compareAndSet(/*expect=*/ null, /*update=*/ DetailedExitCode.of(failureDetail));
errorCode.compareAndSet(
/*expectedValue=*/ null, /*newValue=*/ DetailedExitCode.of(failureDetail));
} else {
BugReport.sendBugReport(
new IllegalStateException("Undetailed error from package: " + node));
BugReport.sendBugReport(new UndetailedErrorFromPackageException(node));
}
}
}

private static final class UndetailedErrorFromPackageException extends RuntimeException
implements NonFatalBugReport {
UndetailedErrorFromPackageException(Target node) {
super("Undetailed error from package: " + node);
}
}
}

0 comments on commit 74fff55

Please sign in to comment.