From 48bd3c77ad1dff2bd3b39a8c97245c49024966e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Fri, 20 May 2016 17:01:48 +0200 Subject: [PATCH] Handling further parser exceptions. --- src/plasp/sas/Description.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/plasp/sas/Description.cpp b/src/plasp/sas/Description.cpp index 31bec22..1fd01aa 100644 --- a/src/plasp/sas/Description.cpp +++ b/src/plasp/sas/Description.cpp @@ -289,12 +289,19 @@ void Description::parseVariablesSection(std::istream &istream) const auto numberOfValues = parse(istream); variable.values.resize(numberOfValues); - istream.ignore(std::numeric_limits::max(), '\n'); - - for (size_t j = 0; j < numberOfValues; j++) + try { - auto &value = variable.values[j]; - std::getline(istream, value.name); + istream.ignore(std::numeric_limits::max(), '\n'); + + for (size_t j = 0; j < numberOfValues; j++) + { + auto &value = variable.values[j]; + std::getline(istream, value.name); + } + } + catch (const std::exception &e) + { + throw ParserException("Could not parse variable " + variable.name + " (" + e.what() + ")"); } parseSectionIdentifier(istream, "end_variable");