Skip to content

Commit

Permalink
Remove special handling of IOException
Browse files Browse the repository at this point in the history
Summary:
In Build.executeAndPrintFailures, this changes IOException to be
classified as an internal error. This means that they will be printed
with their stack trace (and preceded by a message saying that it's a
buck internal error).

Any IOExceptions that are actually due to user errors should be updated
to be wrapped in a HumanReadableException.

Test Plan: CI, updated tests

Reviewed By: ttsugriy

fbshipit-source-id: a2fba52
  • Loading branch information
cjhopman authored and facebook-github-bot committed Oct 3, 2017
1 parent b3a40eb commit 0e078a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
14 changes: 0 additions & 14 deletions src/com/facebook/buck/command/Build.java
Original file line number Diff line number Diff line change
Expand Up @@ -358,20 +358,6 @@ private void reportExceptionToUser(BuckEventBus eventBus, Exception e) {
e = rootCauseOfBuildException(e);
}
new ErrorLogger(eventBus, "Build failed: ", "Got an exception during the build.") {
@Override
protected void logUserVisible(Exception rootCause, List<String> context) {
// Convert some causes to HumanReadableException to preserve historic behavior.
// TODO(cjhopman): We shouldn't do this. We should update StepFailedException to be like
// BuckExecutionException and update places that might throw IOException to create
// HumanReadableExceptions if it's due to user error.
if (rootCause instanceof IOException) {
rootCause =
new HumanReadableException(
rootCause.getClass().getName() + " " + rootCause.getMessage());
}
super.logUserVisible(rootCause, context);
}

@Override
protected String getMessageForRootCause(Exception rootCause) {
if (rootCause instanceof HumanReadableException) {
Expand Down
15 changes: 12 additions & 3 deletions test/com/facebook/buck/cli/BuildCommandErrorsIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ public void ioExceptionThrownInStep() throws Exception {
ProjectWorkspace.ProcessResult result = workspace.runBuckBuild(":target_name");
result.assertFailure();
assertEquals(
"Build failed: java.io.IOException failure message\n"
"Buck encountered an internal error\n"
+ "java.io.IOException: failure message\n"
+ "<stacktrace>\n"
+ "\n"
+ " When running <failing_step>.\n"
+ " When building rule //:target_name.",
getError(getStderr(result)));
Expand All @@ -203,7 +206,10 @@ public void ioExceptionThrown() throws Exception {
ProjectWorkspace.ProcessResult result = workspace.runBuckBuild(":target_name");
result.assertFailure();
assertEquals(
"Build failed: java.io.IOException failure message\n"
"Buck encountered an internal error\n"
+ "java.io.IOException: failure message\n"
+ "<stacktrace>\n"
+ "\n"
+ " When building rule //:target_name.",
getError(getStderr(result)));
}
Expand All @@ -215,7 +221,10 @@ public void ioExceptionWithRuleInMessageThrown() throws Exception {
ProjectWorkspace.ProcessResult result = workspace.runBuckBuild(":target_name");
result.assertFailure();
assertEquals(
"Build failed: java.io.IOException failure message //:target_name\n"
"Buck encountered an internal error\n"
+ "java.io.IOException: failure message //:target_name\n"
+ "<stacktrace>\n"
+ "\n"
+ " When building rule //:target_name.",
getError(getStderr(result)));
}
Expand Down

0 comments on commit 0e078a6

Please sign in to comment.