Skip to content
Snippets Groups Projects
Commit 7c42816e authored by dgelessus's avatar dgelessus
Browse files

Add causes to thrown exceptions where possible

parent f6e629b3
No related branches found
No related tags found
No related merge requests found
...@@ -358,7 +358,7 @@ public class TLC4B { ...@@ -358,7 +358,7 @@ public class TLC4B {
} catch (ParseException e) { } catch (ParseException e) {
HelpFormatter formatter = new HelpFormatter(); HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("[file]", options); formatter.printHelp("[file]", options);
throw new TLC4BIOException(e.getMessage()); throw new TLC4BIOException(e);
} }
} }
...@@ -415,7 +415,7 @@ public class TLC4B { ...@@ -415,7 +415,7 @@ public class TLC4B {
try { try {
mainfile = mainfile.getCanonicalFile(); mainfile = mainfile.getCanonicalFile();
} catch (IOException e) { } catch (IOException e) {
throw new TLC4BIOException("The file '" + mainfile.getPath() + "' can not be accessed."); throw new TLC4BIOException("The file '" + mainfile.getPath() + "' can not be accessed.", e);
} }
machineFileNameWithoutFileExtension = mainfile.getName().substring(0, machineFileNameWithoutFileExtension = mainfile.getName().substring(0,
...@@ -493,7 +493,7 @@ public class TLC4B { ...@@ -493,7 +493,7 @@ public class TLC4B {
fw.close(); fw.close();
println("Log file: " + logFile.getAbsolutePath()); println("Log file: " + logFile.getAbsolutePath());
} catch (IOException e) { } catch (IOException e) {
throw new TLC4BIOException(e.getLocalizedMessage()); throw new TLC4BIOException(e);
} }
} }
} }
...@@ -546,7 +546,7 @@ public class TLC4B { ...@@ -546,7 +546,7 @@ public class TLC4B {
} }
println("Standard module '" + file.getName() + "' created."); println("Standard module '" + file.getName() + "' created.");
} catch (IOException e) { } catch (IOException e) {
throw new TLC4BIOException(e.getMessage()); throw new TLC4BIOException(e);
} finally { } finally {
if (TLC4BGlobals.isDeleteOnExit() && file.exists()) { if (TLC4BGlobals.isDeleteOnExit() && file.exists()) {
file.deleteOnExit(); file.deleteOnExit();
...@@ -560,7 +560,7 @@ public class TLC4B { ...@@ -560,7 +560,7 @@ public class TLC4B {
fos.close(); fos.close();
} }
} catch (IOException ex) { } catch (IOException ex) {
throw new TLC4BIOException(ex.getMessage()); throw new TLC4BIOException(ex);
} }
} }
} }
...@@ -576,7 +576,7 @@ public class TLC4B { ...@@ -576,7 +576,7 @@ public class TLC4B {
out.close(); out.close();
return file; return file;
} catch (IOException e) { } catch (IOException e) {
throw new TLC4BIOException(e.getMessage()); throw new TLC4BIOException(e);
} finally { } finally {
if (deleteOnExit && exists) { if (deleteOnExit && exists) {
file.deleteOnExit(); file.deleteOnExit();
......
...@@ -69,7 +69,7 @@ public class Translator { ...@@ -69,7 +69,7 @@ public class Translator {
try { try {
start = parser.parseFile(machineFile); start = parser.parseFile(machineFile);
} catch (NoClassDefFoundError e) { } catch (NoClassDefFoundError e) {
throw new TLC4BIOException("Definitions file cannot be found."); throw new TLC4BIOException("Definitions file cannot be found.", e);
} }
// Definitions of definitions files are injected in the ast of the main // Definitions of definitions files are injected in the ast of the main
......
...@@ -84,9 +84,7 @@ public class DefinitionsAnalyser extends DepthFirstAdapter { ...@@ -84,9 +84,7 @@ public class DefinitionsAnalyser extends DepthFirstAdapter {
int value = Integer.parseInt(sizeExpr.getLiteral().getText()); int value = Integer.parseInt(sizeExpr.getLiteral().getText());
TLC4BGlobals.setDEFERRED_SET_SIZE(value); TLC4BGlobals.setDEFERRED_SET_SIZE(value);
} catch (ClassCastException e) { } catch (ClassCastException e) {
throw new TranslationException( throw new TranslationException("Unable to determine the default set size from definition SET_PREF_DEFAULT_SETSIZE: " + node.getEndPos(), e);
"Unable to determine the default set size from definition SET_PREF_DEFAULT_SETSIZE: "
+ node.getEndPos());
} }
} }
...@@ -98,9 +96,7 @@ public class DefinitionsAnalyser extends DepthFirstAdapter { ...@@ -98,9 +96,7 @@ public class DefinitionsAnalyser extends DepthFirstAdapter {
int value = Integer.parseInt(sizeExpr.getLiteral().getText()); int value = Integer.parseInt(sizeExpr.getLiteral().getText());
TLC4BGlobals.setMAX_INT(value); TLC4BGlobals.setMAX_INT(value);
} catch (ClassCastException e) { } catch (ClassCastException e) {
throw new TranslationException( throw new TranslationException("Unable to determine MAXINT from definition SET_PREF_MAXINT: " + node.getEndPos(), e);
"Unable to determine MAXINT from definition SET_PREF_MAXINT: "
+ node.getEndPos());
} }
} }
...@@ -121,8 +117,7 @@ public class DefinitionsAnalyser extends DepthFirstAdapter { ...@@ -121,8 +117,7 @@ public class DefinitionsAnalyser extends DepthFirstAdapter {
} }
TLC4BGlobals.setMIN_INT(value); TLC4BGlobals.setMIN_INT(value);
} catch (ClassCastException e) { } catch (ClassCastException e) {
throw new TranslationException( throw new TranslationException("Unable to determine the MININT from definition SET_PREF_MININT: " + node.getEndPos(), e);
"Unable to determine the MININT from definition SET_PREF_MININT: " + node.getEndPos());
} }
} }
} }
......
...@@ -331,7 +331,7 @@ public class MachineContext extends DepthFirstAdapter { ...@@ -331,7 +331,7 @@ public class MachineContext extends DepthFirstAdapter {
try { try {
identifierAlreadyExists(name); identifierAlreadyExists(name);
} catch (ScopeException e2) { } catch (ScopeException e2) {
throw new ScopeException("Machine '" + name + "' is seen twice."); throw new ScopeException("Machine '" + name + "' is seen twice.", e2);
} }
seenMachines.put(name, p); seenMachines.put(name, p);
} }
......
This diff is collapsed.
...@@ -78,7 +78,7 @@ public class LTLFormulaVisitor extends DepthFirstAdapter { ...@@ -78,7 +78,7 @@ public class LTLFormulaVisitor extends DepthFirstAdapter {
this.ltlFormulaStart = parseLTLFormula(ltlFormula); this.ltlFormulaStart = parseLTLFormula(ltlFormula);
} catch (Exception e) { } catch (Exception e) {
String message = "Parsing definition " + name + " (line " + def.getStartPos().getLine() + "):\n"; String message = "Parsing definition " + name + " (line " + def.getStartPos().getLine() + "):\n";
throw new LTLParseException(message + e.getMessage()); throw new LTLParseException(message + e.getMessage(), e);
} }
} }
...@@ -86,7 +86,7 @@ public class LTLFormulaVisitor extends DepthFirstAdapter { ...@@ -86,7 +86,7 @@ public class LTLFormulaVisitor extends DepthFirstAdapter {
try { try {
this.ltlFormulaStart = parseLTLFormula(ltlString); this.ltlFormulaStart = parseLTLFormula(ltlString);
} catch (Exception e) { } catch (Exception e) {
throw new LTLParseException(e.getMessage()); throw new LTLParseException(e);
} }
} }
...@@ -155,7 +155,7 @@ public class LTLFormulaVisitor extends DepthFirstAdapter { ...@@ -155,7 +155,7 @@ public class LTLFormulaVisitor extends DepthFirstAdapter {
try { try {
start = parser.parsePredicate(text); start = parser.parsePredicate(text);
} catch (BCompoundException e) { } catch (BCompoundException e) {
throw new LTLParseException(e.getMessage()); throw new LTLParseException(e);
} }
return start; return start;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment