Skip to content
Snippets Groups Projects
Commit 200a7291 authored by dgelessus's avatar dgelessus
Browse files

Unwrap some TLC4BIOException where IOException also works

parent 61916f55
No related branches found
No related tags found
No related merge requests found
...@@ -128,7 +128,7 @@ public class TLC4B { ...@@ -128,7 +128,7 @@ public class TLC4B {
} }
} }
private void printResults(TLCResults results) { private void printResults(TLCResults results) throws IOException {
printOperationsCount(results); printOperationsCount(results);
// options // options
printlnSilent("Used Options"); printlnSilent("Used Options");
...@@ -476,20 +476,18 @@ public class TLC4B { ...@@ -476,20 +476,18 @@ public class TLC4B {
return sb.toString(); return sb.toString();
} }
private void createLogFile(TLCResults results) { private void createLogFile(TLCResults results) throws IOException {
if (logFile != null) { if (logFile != null) {
String logCsvString = getLogCsvString(results); String logCsvString = getLogCsvString(results);
try (FileWriter fw = new FileWriter(logFile, true)) { // the true will append the new data try (FileWriter fw = new FileWriter(logFile, true)) { // the true will append the new data
fw.write(logCsvString); fw.write(logCsvString);
fw.close(); fw.close();
println("Log file: " + logFile.getAbsolutePath()); println("Log file: " + logFile.getAbsolutePath());
} catch (IOException e) {
throw new TLC4BIOException(e);
} }
} }
} }
private void createFiles() { private void createFiles() throws IOException {
boolean dirCreated = buildDir.mkdir(); boolean dirCreated = buildDir.mkdir();
if (dirCreated && TLC4BGlobals.isDeleteOnExit()) { if (dirCreated && TLC4BGlobals.isDeleteOnExit()) {
buildDir.deleteOnExit(); buildDir.deleteOnExit();
...@@ -508,13 +506,13 @@ public class TLC4B { ...@@ -508,13 +506,13 @@ public class TLC4B {
createStandardModules(); createStandardModules();
} }
private void createStandardModules() { private void createStandardModules() throws IOException {
for (String module : translator.getStandardModuleToBeCreated()) { for (String module : translator.getStandardModuleToBeCreated()) {
createStandardModule(buildDir, module); createStandardModule(buildDir, module);
} }
} }
private void createStandardModule(File path, String name) { private void createStandardModule(File path, String name) throws IOException {
// standard modules are copied from the standardModules folder to the current directory // standard modules are copied from the standardModules folder to the current directory
File file = new File(path, name + ".tla"); File file = new File(path, name + ".tla");
...@@ -536,13 +534,10 @@ public class TLC4B { ...@@ -536,13 +534,10 @@ public class TLC4B {
fos.write(bytes, 0, read); fos.write(bytes, 0, read);
} }
println("Standard module '" + file.getName() + "' created."); println("Standard module '" + file.getName() + "' created.");
} catch (IOException e) {
throw new TLC4BIOException(e);
} finally { } finally {
if (TLC4BGlobals.isDeleteOnExit() && file.exists()) { if (TLC4BGlobals.isDeleteOnExit() && file.exists()) {
file.deleteOnExit(); file.deleteOnExit();
} }
try {
if (is != null) { if (is != null) {
is.close(); is.close();
} }
...@@ -550,13 +545,10 @@ public class TLC4B { ...@@ -550,13 +545,10 @@ public class TLC4B {
fos.flush(); fos.flush();
fos.close(); fos.close();
} }
} catch (IOException ex) {
throw new TLC4BIOException(ex);
}
} }
} }
private static File createFile(File dir, String fileName, String text, boolean deleteOnExit) { private static File createFile(File dir, String fileName, String text, boolean deleteOnExit) throws IOException {
File file = new File(dir, fileName); File file = new File(dir, fileName);
boolean exists = false; boolean exists = false;
try { try {
...@@ -566,8 +558,6 @@ public class TLC4B { ...@@ -566,8 +558,6 @@ public class TLC4B {
out.write(text); out.write(text);
out.close(); out.close();
return file; return file;
} catch (IOException e) {
throw new TLC4BIOException(e);
} finally { } finally {
if (deleteOnExit && exists) { if (deleteOnExit && exists) {
file.deleteOnExit(); file.deleteOnExit();
......
...@@ -28,7 +28,6 @@ import de.tlc4b.analysis.transformation.SetComprehensionOptimizer; ...@@ -28,7 +28,6 @@ import de.tlc4b.analysis.transformation.SetComprehensionOptimizer;
import de.tlc4b.analysis.typerestriction.TypeRestrictor; import de.tlc4b.analysis.typerestriction.TypeRestrictor;
import de.tlc4b.analysis.unchangedvariables.InvariantPreservationAnalysis; import de.tlc4b.analysis.unchangedvariables.InvariantPreservationAnalysis;
import de.tlc4b.analysis.unchangedvariables.UnchangedVariablesFinder; import de.tlc4b.analysis.unchangedvariables.UnchangedVariablesFinder;
import de.tlc4b.exceptions.TLC4BIOException;
import de.tlc4b.prettyprint.TLAPrinter; import de.tlc4b.prettyprint.TLAPrinter;
import de.tlc4b.tla.Generator; import de.tlc4b.tla.Generator;
import de.tlc4b.tlc.TLCOutputInfo; import de.tlc4b.tlc.TLCOutputInfo;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment