From 12c91d0c9fc8b9e400aae47058ae41d92602f6eb Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 25 Oct 2015 21:18:38 +0000 Subject: Throw IOException rather than wrapping in RuntimeException --- .../zwobble/couscous/frontends/java/JavaFrontend.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/main/java/org/zwobble/couscous/frontends') diff --git a/src/main/java/org/zwobble/couscous/frontends/java/JavaFrontend.java b/src/main/java/org/zwobble/couscous/frontends/java/JavaFrontend.java index d7bd54f..f58e6af 100644 --- a/src/main/java/org/zwobble/couscous/frontends/java/JavaFrontend.java +++ b/src/main/java/org/zwobble/couscous/frontends/java/JavaFrontend.java @@ -4,26 +4,21 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; + import org.zwobble.couscous.ast.ClassNode; +import org.zwobble.couscous.util.ExtraLists; public class JavaFrontend { public static List readSourceDirectory(Path directoryPath) throws IOException { JavaReader reader = new JavaReader(); - return findJavaFiles(directoryPath) - .map(javaFile -> { - // TODO: unwrap exception in outer scope - try { - return reader.readClassFromFile(directoryPath, javaFile); - } catch (Exception e) { - throw new RuntimeException(e); - } - }) - .collect(Collectors.toList()); + return ExtraLists.map( + findJavaFiles(directoryPath), + javaFile -> reader.readClassFromFile(directoryPath, javaFile)); } private static Stream findJavaFiles(Path directoryPath) throws IOException { - return Files.walk(directoryPath).filter(path -> path.toFile().isFile() && path.toString().endsWith(".java")); + return Files.walk(directoryPath) + .filter(path -> path.toFile().isFile() && path.toString().endsWith(".java")); } } \ No newline at end of file -- cgit v1.2.3