Moved exception catching from parser to application.

This commit is contained in:
Patrick Lühne 2016-05-20 16:16:56 +02:00
parent 3ddf942a12
commit d7984e9b3a
2 changed files with 19 additions and 20 deletions

View File

@ -37,8 +37,15 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
const auto sasDescription = plasp::sas::Description::fromFile(variablesMap["input"].as<std::string>());
sasDescription.print(std::cout);
try
{
const auto sasDescription = plasp::sas::Description::fromFile(variablesMap["input"].as<std::string>());
sasDescription.print(std::cout);
}
catch (const std::exception &e)
{
std::cerr << "Error: " << e.what() << std::endl;
}
return EXIT_SUCCESS;
}

View File

@ -36,25 +36,17 @@ Description Description::fromFile(const boost::filesystem::path &path)
return description;
}
try
{
std::ifstream fileStream(path.string(), std::ios::in);
fileStream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
std::ifstream fileStream(path.string(), std::ios::in);
fileStream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
description.parseVersionSection(fileStream);
description.parseMetricSection(fileStream);
description.parseVariablesSection(fileStream);
description.parseMutexSection(fileStream);
description.parseInitialStateSection(fileStream);
description.parseGoalSection(fileStream);
description.parseOperatorSection(fileStream);
description.parseAxiomSection(fileStream);
}
catch (std::exception &exception)
{
std::cerr << "Error: " << exception.what() << std::endl;
return description;
}
description.parseVersionSection(fileStream);
description.parseMetricSection(fileStream);
description.parseVariablesSection(fileStream);
description.parseMutexSection(fileStream);
description.parseInitialStateSection(fileStream);
description.parseGoalSection(fileStream);
description.parseOperatorSection(fileStream);
description.parseAxiomSection(fileStream);
return description;
}