Skip to content
Snippets Groups Projects
Commit 0a0d3567 authored by Mick Jordan's avatar Mick Jordan
Browse files

add Utils.fail

parent 8a14328e
Branches
No related tags found
No related merge requests found
......@@ -132,4 +132,10 @@ public final class Utils {
}
}
public static void fail(String msg) {
// CheckStyle: stop system..print check
System.err.println("FastR internal error: " + msg);
System.exit(1);
}
}
......@@ -53,7 +53,7 @@ public class JLineConsoleHandler implements RContext.ConsoleHandler {
try {
return console.readLine();
} catch (IOException ex) {
RCommand.fail("unexpected error reading console input");
Utils.fail("unexpected error reading console input");
return null;
}
}
......
......@@ -82,18 +82,13 @@ public class RCommand {
try {
console = new RJLineConsoleReader(consoleInput, consoleOutput);
} catch (IOException ex) {
fail("unexpected error opening console reader");
Utils.fail("unexpected error opening console reader");
}
readEvalPrint(consoleInput == System.in, console, commandArgs);
}
// TODO exit code
}
static void fail(String msg) {
System.err.println(msg);
System.exit(1);
}
private static void printVersionAndExit() {
System.out.print("FastR version ");
System.out.println(RRuntime.FASTR_VERSION);
......@@ -109,7 +104,7 @@ public class RCommand {
private static void evalFileInput(String filePath, String[] commandArgs) {
File file = new File(filePath);
if (!file.exists()) {
fail("Fatal error: cannot open file '" + filePath + "': No such file or directory");
Utils.fail("Fatal error: cannot open file '" + filePath + "': No such file or directory");
}
try (BufferedInputStream is = new BufferedInputStream(new FileInputStream(file))) {
byte[] bytes = new byte[(int) file.length()];
......@@ -119,7 +114,7 @@ public class RCommand {
REngine engine = REngine.getInstance(commandArgs, consoleHandler);
engine.parseAndEval(content, REngine.createVirtualFrame(), true);
} catch (IOException ex) {
fail("unexpected error reading file input");
Utils.fail("unexpected error reading file input");
}
}
......@@ -144,7 +139,7 @@ public class RCommand {
} catch (UserInterruptException e) {
// interrupted
} catch (IOException ex) {
fail("unexpected error reading console input");
Utils.fail("unexpected error reading console input");
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment