Handle top-level exceptions in javac
javac's main catches all exceptions and returns an exit code, the API does not.
This restores error handling that was lost when we migrated to the API in
commit
MOS_MIGRATED_REVID=144457176
@@ -120,7 +120,6 @@ public class BlazeJavacMain {
setupBlazeJavaCompiler(context);
Result result = Result.ABNORMAL;
- try {
JavacTool tool = JavacTool.create();
JavacTaskImpl task =
(JavacTaskImpl)
@@ -137,16 +136,18 @@ public class BlazeJavacMain {
}
fileManager.setContext(context);
setLocations(fileManager, arguments);
+ try {
+ try {
result = task.doCall();
} catch (PropagatedException e) {
- if (e.getCause() instanceof PluginException) {
- PluginException pluginException = (PluginException) e.getCause();
- errOutput.println(pluginException.getMessage());
- result = pluginException.getResult();
- } else {
- e.printStackTrace(errOutput);
- result = Result.ABNORMAL;
+ throw e.getCause();
}
+ } catch (PluginException e) {
+ errOutput.println(e.getMessage());
+ result = e.getResult();
+ } catch (Throwable t) {
+ t.printStackTrace(errOutput);
+ result = Result.ABNORMAL;
} finally {
if (result.isOK()) {
verifyNotNull(compiler);
