Handle and report exception thrown by checkstyle

Change-Id: I041fd0d4787ddff80a206e47688524984f3500ff
This commit is contained in:
Ray Milkey 2016-11-16 11:03:32 -08:00 committed by Brian O'Connor
parent e6067899ad
commit 8df94b8f23
2 changed files with 10 additions and 3 deletions

View File

@ -21,6 +21,7 @@ import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
import org.onosproject.checkstyle.CheckstyleRunner; import org.onosproject.checkstyle.CheckstyleRunner;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream;
import java.net.ServerSocket; import java.net.ServerSocket;
import java.net.Socket; import java.net.Socket;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -176,9 +177,14 @@ public final class BuckDaemon {
BuckTask task = tasks.get(taskName); BuckTask task = tasks.get(taskName);
if (task != null) { if (task != null) {
System.out.println(String.format("Executing task '%s'", taskName)); System.out.println(String.format("Executing task '%s'", taskName));
task.execute(context); try {
for (String line : context.output()) { task.execute(context);
output(socket, line); for (String line : context.output()) {
output(socket, line);
}
// TODO should we catch Exception, RuntimeException, or something specific?
} catch (Throwable e) {
e.printStackTrace(new PrintStream(socket.getOutputStream()));
} }
} else { } else {
String message = String.format("No task named '%s'", taskName); String message = String.format("No task named '%s'", taskName);

View File

@ -91,6 +91,7 @@ public class CheckstyleRunner implements BuckTask {
listener.await(); listener.await();
} catch (CheckstyleException | InterruptedException e) { } catch (CheckstyleException | InterruptedException e) {
e.printStackTrace(); //dump exeception to stderr
throw new RuntimeException(e); throw new RuntimeException(e);
} finally { } finally {
checker.destroy(); checker.destroy();