diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-10-31 13:00:36 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-10-31 13:00:36 +0000 |
| commit | ccbcd95c177ef9725ed772504e33310474835b57 (patch) | |
| tree | 44a1f8c276550a7a535571123e1e910e52411106 /src | |
| parent | a4ffd9468c4bf3bd9da9b40cb336eb91bfdbf987 (diff) | |
Don't hide IOException
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/java/org/zwobble/couscous/backends/python/PythonCompiler.java | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/main/java/org/zwobble/couscous/backends/python/PythonCompiler.java b/src/main/java/org/zwobble/couscous/backends/python/PythonCompiler.java index b829bec..c8f9932 100644 --- a/src/main/java/org/zwobble/couscous/backends/python/PythonCompiler.java +++ b/src/main/java/org/zwobble/couscous/backends/python/PythonCompiler.java @@ -27,19 +27,15 @@ public class PythonCompiler { this.packageName = packageName; } - public void compile(List<ClassNode> classes) { + public void compile(List<ClassNode> classes) throws IOException { for (ClassNode classNode : classes) { compileClass(classNode); } for (String runtimeFile : RUNTIME_FILES) { - try { - String path = relativePathForModule(runtimeFile); - writeModule( - runtimeFile, - Resources.toString(Resources.getResource("python/runtime/" + path), StandardCharsets.UTF_8)); - } catch (IOException e) { - throw new RuntimeException(e); - } + String path = relativePathForModule(runtimeFile); + writeModule( + runtimeFile, + Resources.toString(Resources.getResource("python/runtime/" + path), StandardCharsets.UTF_8)); } } @@ -51,21 +47,17 @@ public class PythonCompiler { return moduleName.replace(".", File.separator) + ".py"; } - private void compileClass(ClassNode classNode) { + private void compileClass(ClassNode classNode) throws IOException { writeModule( classNode.getName().getQualifiedName(), serialize(generateCode(classNode))); } - private void writeModule(String name, String contents) { + private void writeModule(String name, String contents) throws IOException { Path path = destinationPathForModule(name); - try { - Files.createDirectories(path.getParent()); - createPythonPackages(path.getParent()); - Files.write(path, asList(contents)); - } catch (final java.lang.Throwable $ex) { - throw new RuntimeException($ex); - } + Files.createDirectories(path.getParent()); + createPythonPackages(path.getParent()); + Files.write(path, asList(contents)); } private void createPythonPackages(Path packagePath) throws IOException { |
