mv try-block

This commit is contained in:
Christopher Dunn 2015-01-23 11:36:55 -06:00
parent 08cfd02d8c
commit 58c31ac550

View File

@ -242,17 +242,10 @@ static int parseCommandLine(
opts->path = argv[index]; opts->path = argv[index];
return 0; return 0;
} }
static void tryTest(Options const& opts) static int runTest(Options const& opts)
{ {
} int exitCode = 0;
int main(int argc, const char* argv[]) {
Options opts;
int exitCode = parseCommandLine(argc, argv, &opts);
if (exitCode != 0) {
return exitCode;
}
try {
std::string input = readInputTestFile(opts.path.c_str()); std::string input = readInputTestFile(opts.path.c_str());
if (input.empty()) { if (input.empty()) {
printf("Failed to read input or empty input: %s\n", opts.path.c_str()); printf("Failed to read input or empty input: %s\n", opts.path.c_str());
@ -289,11 +282,20 @@ int main(int argc, const char* argv[]) {
if (exitCode) { if (exitCode) {
return exitCode; return exitCode;
} }
return 0;
}
int main(int argc, const char* argv[]) {
Options opts;
int exitCode = parseCommandLine(argc, argv, &opts);
if (exitCode != 0) {
printf("Failed to parse command-line.");
return exitCode;
}
try {
return runTest(opts);
} }
catch (const std::exception& e) { catch (const std::exception& e) {
printf("Unhandled exception:\n%s\n", e.what()); printf("Unhandled exception:\n%s\n", e.what());
exitCode = 1; return 1;
} }
return exitCode;
} }