Commit f990b135 authored by Jonathan Shahen's avatar Jonathan Shahen

Better Error Control (remember that logger.severe does not cut the program...

Better Error Control (remember that logger.severe does not cut the program there, it will continue running so throw a new error after reporting it)
parent ab80f376
package mohawk.helper;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.io.*;
import java.util.*;
import java.util.logging.Logger;
import mohawk.output.WriteNuSMV;
......@@ -88,11 +83,12 @@ public class SMVSpecHelper {
specFiles.add(file2);
}
public void convertSpecToSMVFormat(File specFile, File nusmvFile) {
public void convertSpecToSMVFormat(File specFile, File nusmvFile) throws Exception {
logger.info("Converting the Spec file (" + specFile.getName() + ") to their SMV format...");
if (!specFile.exists()) {
logger.severe("[ERROR] Unable to find the SPEC file: " + specFile.getName());
throw new FileNotFoundException("Unable to find the SPEC file: " + specFile.getName());
}
try {
......@@ -128,11 +124,15 @@ public class SMVSpecHelper {
nusmv.writeFile();
} catch (IOException e1) {
logger.severe("[ERROR] Unable to write to the SMV file: " + nusmvFile.getAbsolutePath());
throw e1;
} catch (Exception e) {
StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors));
logger.severe(errors.toString());
logger.severe(e.getMessage());
throw e;
}
logger.info("Done converting Spec file to their SMV format.");
......
......@@ -169,8 +169,9 @@ public class TestingSuite {
} else {
lastResult = future.get(smvHelper.TIMEOUT_SECONDS, TimeUnit.SECONDS);
}
System.out.println("Result: " + lastResult);
logger.info("[COMPLETED] Result: " + lastResult + ", for the following spec file (in mode "
System.out.println("Result: " + lastResult + " for role '" + absrefine.getSpecRole() + "'");
logger.info("[COMPLETED] Result: " + lastResult + ", for the Spec Role: '" + absrefine.getSpecRole()
+ "' in following spec file (in mode "
+ modes.get(j) + "): " + specFile);
/* TIMING */timing.stopTimer(timerName);
......@@ -228,17 +229,24 @@ public class TestingSuite {
smvHelper.loadSpecFiles();
for (int i = 0; i < smvHelper.specFiles.size(); i++) {
File specFile = smvHelper.specFiles.get(i);
File nusmvFile = smvHelper.getSmvFile(specFile);
logger.info("[FILE IO] Using SMV File: " + nusmvFile.getCanonicalPath());
smvHelper.convertSpecToSMVFormat(specFile, nusmvFile);
// This option is available for testing purposes as there isn't a
// practical reason to convert and immediately delete
if (smvHelper.smvDeleteFile) {
logger.fine("[FILE IO] Deleting SMV File: " + nusmvFile.getName());
nusmvFile.delete();
try {
File specFile = smvHelper.specFiles.get(i);
File nusmvFile = smvHelper.getSmvFile(specFile);
logger.info("[FILE IO] Using SMV File: " + nusmvFile.getCanonicalPath());
smvHelper.convertSpecToSMVFormat(specFile, nusmvFile);
// This option is available for testing purposes as there isn't a
// practical reason to convert and immediately delete
if (smvHelper.smvDeleteFile) {
logger.fine("[FILE IO] Deleting SMV File: " + nusmvFile.getName());
nusmvFile.delete();
}
} catch (Exception e) {
StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors));
logger.severe(errors.toString());
logger.severe(e.getMessage());
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment