Commit 301e2aa6 authored by Carlos Galindo's avatar Carlos Galindo
Browse files

Improved error handling when parsing fails

parent 62753294
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ public class ErlangLASTFactory extends LASTFactory
		final Launcher launcher = Launcher.getLauncher();
		final OtpErlangObject response = launcher.launch("ast", "getASTs", sourcePath);
		final OtpErlangTuple tuple = (OtpErlangTuple) response;
		if (!(tuple.elementAt(1) instanceof OtpErlangList))
			throw new RuntimeException("The erlang program could not be loaded: " + tuple.elementAt(1).toString());
		final OtpErlangList asts = (OtpErlangList) tuple.elementAt(1);
		final ErlangLASTFactory lastFactory = new ErlangLASTFactory(sourcePath);

@@ -186,6 +188,8 @@ public class ErlangLASTFactory extends LASTFactory
					break;
				case "eof":
					break;
				case "error":
					throw new RuntimeException("Parsing of the Erlang code has failed. Re-check the input program.");
				default:
					throw new RuntimeException("Type not contemplated: " + type.atomValue());
			}